Forum: RSpec [rails] undefined method `handling_predicate!'

Posted by Dan Steinicke (Guest)
on 2010-01-21 04:04
(Received via mailing list)
I'm trying to use authlogic and factory_girl with rspec  and I am
getting an error I don't understand.  Basically I have this failing
spec:

it "should succeed in creating a user from a factory" do
     testuser = Factory.create(:user)
     debugger
     testuser.should be_valid
end

When I stop in the debugger I see this:

(rdb:1) testuser.valid?
true
(rdb:1) testuser.should be_valid
NoMethodError Exception: undefined method `handling_predicate!' for
#<Spec::Matchers::Be:0x25a9cac @args=[:be_valid]>

My (limited) understanding of rSpec is that if the "testuser.valid?"
works then "testuser.should be_valid" should work as well.  I'm
confused because its not working.

Can someone help me understand what is going on here?

I am using the following gem versions:
rspec (1.3.0)
rspec-rails (1.3.2)
authlogic (2.1.3)
factory_girl (1.2.3)
rails (2.3.5)

I have uninstalled/ reinstalled rspec, rspec-rails and rerun
script/generate rspec letting it overwrite everything.

Gist with full terminal output from running the spec and files:
http://gist.github.com/282045
spec/models/user_spec.rb
spec/spec_helper.rb
spec/factories/users.rb

thanks
Dan Steinicke
Posted by David Chelimsky (Guest)
on 2010-01-21 04:09
(Received via mailing list)
On Wed, Jan 20, 2010 at 12:00 PM, Dan Steinicke <dansteinicke@gmail.com> 
wrote:
> When I stop in the debugger I see this:
>
> script/generate rspec letting it overwrite everything.
>
> Gist with full terminal output from running the spec and files:
> http://gist.github.com/282045
> spec/models/user_spec.rb
> spec/spec_helper.rb
> spec/factories/users.rb
>
> thanks
> Dan Steinicke

Hey Dan,

If you're seeing that error it means you have an older version of
rspec-rails than 1.3.2 that is being loaded. Try running the spec with
--backtrace so you can see a full backtrace. Do you see any other
versions being loaded? Maybe from vendor/plugins?
Posted by DanS (Guest)
on 2010-01-21 23:52
(Received via mailing list)
On Jan 20, 7:07 pm, David Chelimsky <dchelim...@gmail.com> wrote:
>
> > confused because its not working.
> > I have uninstalled/ reinstalled rspec, rspec-rails and rerun
>
> Hey Dan,
>
> If you're seeing that error it means you have an older version of
> rspec-rails than 1.3.2 that is being loaded. Try running the spec with
> --backtrace so you can see a full backtrace. Do you see any other
> versions being loaded? Maybe from vendor/plugins?
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

David,

That indeed was the problem.  The gist from the original post shows
the test run with --backtrace and it does show rspec-rails in vendor/
plugins (I didn't see a version number tho).   I did the following:
rm -fr vendor/plugin/rspec-rails
rm -fr vendor/plugin/rsecp
sudo gem install rspec rspec-rails

After which the spec no longer produces a NoMethodError and in fact
passes.

Thanks for taking the time to help me understand this, I was really
stuck.

Dan
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.