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

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


What do you mean repeated? You mean you can't have an abbreviation with two of the same letters?

Julian

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

> I'm studying Rspec and doing some model's tests.
> 
> I have a table with a field which must have two characters, the field should not be empty and can not be repeated. 
> 
> My doubts is with #.
> 
> describe State do
>   context "validations" do
> 
>     it "The abbreviation should not be empty" do
>       subject.abbreviation = nil
>       subject.should_not be_valid
>     end
>       
>     # I can do like example below or I have to break in parts?
> 
>     it "The abbreviation  should have 2 characters" do
>       subject.abbreviation = "BA"
>       subject.should be_valid
>       
>       subject.abbreviation = "B"
>       subject.should_not be_valid
>       
>       subject.abbreviation = "BAA"
>       subject.should_not be_valid
>     end
> 
>     it "The abbreviation can not be repeated" do
> 
>      # I don't know how to do!
> 
>     end
>   end
> end
> 
> Thanks,
> 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/6bbd4f5f/attachment.html>


More information about the rspec-users mailing list