[rspec-users] [Newbie's Doubt] Model's Tests

Julian Leviston julian at leviston.net
Wed Apr 18 01:30:50 UTC 2012

oh you mean a check for uniqueness.

Is this rails? If it is, pretty sure you can do this:

item = Item.create(:abbreviation => "ab")
duplicate_item = Item.create(:abbreviation => "ab")
duplicate_item.new_record?.should_be true


item = Item.new(:abbreviation => "ab")
item.should_be valid
duplicate_item = Item.new(:abbreviation => "ab")
duplicate_item.should_not be_valid

On 18/04/2012, at 11:11 AM, Luciano Borges wrote:

> 2012/4/17 Julian Leviston <julian at leviston.net>
> What do you mean repeated? You mean you can't have an abbreviation with two of the same letters?
> Julian
> Hi Julian,
> Yes. I cat't have the same abbreviation on the table, I know that I have to put the validation in the model, but, I'd like to test first before change my model.
> Luciano 
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120418/e9aa899a/attachment.html>

More information about the rspec-users mailing list