Hi all, I''m using rspec-rails and have a simple model spec which fails with the following trace: undefined local variable or method `be_valid'' for #<Class: 0x00000102c6e820> (NameError) Full trace: https://gist.github.com/713164 The spec is simple: require ''spec_helper'' describe Deal do describe "it should not allow start dates in the past" do Deal.new.should be_valid end end That above fails. I''m running rspec 2.1.0. Any ideas what could be wrong? I''m searched the list and unfortunately haven''t found anything similar. Is it that rspec-rails isn''t being loaded correctly? All my controller specs work just fine. Thanks!
David Chelimsky
2010-Nov-25 12:19 UTC
[rspec-users] be_valid method undefined on model spec
On Tue, Nov 23, 2010 at 11:32 PM, Rick <rsalsa at gmail.com> wrote:> Hi all, > > I''m using rspec-rails and have a simple model spec which fails with > the following trace: > > undefined local variable or method `be_valid'' for #<Class: > 0x00000102c6e820> (NameError) > > Full trace: https://gist.github.com/713164 > > The spec is simple: > > require ''spec_helper'' > > describe Deal do > > ?describe "it should not allow start dates in the past" doThis ^^ creates an example group, but the next line should be in an example. Change the line ^^ above to: it "should not allow start dates in the past" do That will create an example (as opposed to a group). HTH, David> ? ?Deal.new.should be_valid > ?end > > end > > > That above fails. I''m running rspec 2.1.0. Any ideas what could be > wrong? I''m searched the list and unfortunately haven''t found anything > similar. Is it that rspec-rails isn''t being loaded correctly? All my > controller specs work just fine. > > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Pedro Brasileiro
2010-Nov-25 18:31 UTC
[rspec-users] be_valid method undefined on model spec
Try Deal.new.should be_valid? On Thu, Nov 25, 2010 at 9:19 AM, David Chelimsky <dchelimsky at gmail.com>wrote:> On Tue, Nov 23, 2010 at 11:32 PM, Rick <rsalsa at gmail.com> wrote: > > Hi all, > > > > I''m using rspec-rails and have a simple model spec which fails with > > the following trace: > > > > undefined local variable or method `be_valid'' for #<Class: > > 0x00000102c6e820> (NameError) > > > > Full trace: https://gist.github.com/713164 > > > > The spec is simple: > > > > require ''spec_helper'' > > > > describe Deal do > > > > describe "it should not allow start dates in the past" do > > This ^^ creates an example group, but the next line should be in an > example. Change the line ^^ above to: > > it "should not allow start dates in the past" do > > That will create an example (as opposed to a group). > > HTH, > David > > > Deal.new.should be_valid > > end > > > > end > > > > > > That above fails. I''m running rspec 2.1.0. Any ideas what could be > > wrong? I''m searched the list and unfortunately haven''t found anything > > similar. Is it that rspec-rails isn''t being loaded correctly? All my > > controller specs work just fine. > > > > Thanks! > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Pedro Brasileiro Cardoso Junior http://www.pedrobrasileiro.com.br www.twitter.com/pedrobrasileiro -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101125/08720b9c/attachment.html>
David Chelimsky
2010-Nov-25 19:23 UTC
[rspec-users] be_valid method undefined on model spec
On Nov 25, 2010, at 12:31 PM, Pedro Brasileiro wrote:> Try Deal.new.should be_valid?No, don''t. That doesn''t work, and what I wrote below does :) Cheers, David> > On Thu, Nov 25, 2010 at 9:19 AM, David Chelimsky <dchelimsky at gmail.com> wrote: > On Tue, Nov 23, 2010 at 11:32 PM, Rick <rsalsa at gmail.com> wrote: > > Hi all, > > > > I''m using rspec-rails and have a simple model spec which fails with > > the following trace: > > > > undefined local variable or method `be_valid'' for #<Class: > > 0x00000102c6e820> (NameError) > > > > Full trace: https://gist.github.com/713164 > > > > The spec is simple: > > > > require ''spec_helper'' > > > > describe Deal do > > > > describe "it should not allow start dates in the past" do > > This ^^ creates an example group, but the next line should be in an > example. Change the line ^^ above to: > > it "should not allow start dates in the past" do > > That will create an example (as opposed to a group). > > HTH, > David > > > Deal.new.should be_valid > > end > > > > end > > > > > > That above fails. I''m running rspec 2.1.0. Any ideas what could be > > wrong? I''m searched the list and unfortunately haven''t found anything > > similar. Is it that rspec-rails isn''t being loaded correctly? All my > > controller specs work just fine. > > > > Thanks! > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Pedro Brasileiro Cardoso Junior > http://www.pedrobrasileiro.com.br > www.twitter.com/pedrobrasileiro > > _______________________________________________ > 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/20101125/a8091a57/attachment-0001.html>