[rspec-users] [RSpec] Testing "validates_uniquesness of"
Rodrigo Rosenfeld Rosas
lbocseg at yahoo.com.br
Wed Nov 4 17:40:55 EST 2009
Em 02-11-2009 04:48, Joseph.DelCioppio escreveu:
> Guys,
>
> Getting used to doing BDD, and in my current project I'm trying to
> spec out my model, and in particular the fact that my model must
> validate that one of its fields are unique; in this case, the
> customer's email address.
>
> Simple enough model, a customer, who only has two
> fields. :email_address and :state.
>
> I have a model spec that does the following:
>
> it "ensureness that the customer's email is unique" do
>
> customer.new :email_address => "Joe at Test.com"
It is simple. You should have used this instead:
customer.*create* :email_address => "Joe at Test.com"
When you call new, it doesn't instanciate in database and there is why
the second try suceeds...
Hope that helps,
Rodrigo.
__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/
More information about the rspec-users
mailing list