Hi Juanma,
I do this this way:
describe Model do
def create(options={})
Model.create(options)
end
it "should not allow duplicate names" do
model = create(:name => "name")
new_model = create(:name => "name")
new_model.should have_error_on(:name, :taken)
end
end
--
Matt Berther
http://www.mattberther.com
On Apr 2, 2008, at 2:13 AM, Juanma Cervera wrote:
> Hello
>
> I am learning rspec and trying to especify the activerecord
> validations
> of my models.
>
> How would I make a require_uniqueness_of specification for a field.
> Can I make this with mocks, without touching the database?
> Can somebody point me to some information or plugin for this issue.
>
> Thank you very much.
>
> Juan M. Cervera
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users