[rspec-users] Checking for Range

Andrew WC Brown omen.king at gmail.com
Sun May 27 15:31:45 EDT 2007


Well I get error as such:

1)
NoMethodError in 'Person should require a password within the range of 5..40
characters'
undefined method `range' for "ruby_tuesday":String
./spec/models/person_spec.rb:43:

and I have a feeling that they're right when they say string doesn't have a
range method.

I thought this would work:
person.password.length.should == (5..40)

but doesn't look so

1)
ArgumentError in 'Person should require a password within the range of 5..40
characters'
wrong number of arguments (1 for 2)
./spec/models/person_spec.rb:43:in `initialize'
./spec/models/person_spec.rb:43:in `new'
./spec/models/person_spec.rb:43:



On 5/27/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> On 5/27/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > On 5/27/07, Andrew WC Brown <omen.king at gmail.com> wrote:
> > > how would you check for a range using rspec?
> > >
> > > person.password.range.should == Range.new(5..40) <- this doesn't work
> >
> > The correct ruby syntax is Range.new(5, 40). So this should work:
> >
> > person.password.range.should == Range.new(5, 40)
>
> OR ....
>
> person.password.range.should == (5..40) #shortcut for Range.new(5, 40)
>
>
> >
> > Cheers,
> > David
> >
> _______________________________________________
> 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/20070527/6e148572/attachment.html 


More information about the rspec-users mailing list