Rails, Rubymine, RSpec, NoMethodError, Method Missing, Dynamic Finder Methods

I'm trying to run a simple RSpec test inside of RubyMine on top of a rails application. I'm trying to test some generic code inside of a lib directory. The problem is that I get an exception NoMethodError. I can run the same code from "rails console" without any issue.

NoMethodError: undefined method find_or_initialize_by_content_service_id' for #<Class:0x000000048f8f28> /home/justin/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.7/lib/active_record/base.rb:984:inmethod_missing'

So what is needed in RubyMine so that the rails dynamic methods work?

I'm using Rails 3, RubyMine 3.2.4, RSpec 2. Thanks.

1 comment

So what is needed in RubyMine so that the rails dynamic methods work?

Hi all works out of the box, RubyMine doesn't influence on it.

I'm trying to run a simple RSpec test inside of RubyMine on top of a rails application. I'm trying to test some generic code inside of a lib directory. The problem is that I get an exception NoMethodError. I can run the same code from "rails console" without any issue.

NoMethodError: undefined method find_or_initialize_by_content_service_id' for #<Class:0x000000048f8f28> /home/justin/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.7/lib/active_record/base.rb:984:inmethod_missing'

So what is needed in RubyMine so that the rails dynamic methods work?

I'm using Rails 3, RubyMine 3.2.4, RSpec 2. Thanks.

Most likely problem is in your test. Comparision with 'rails console' isn't usefull because rails console launches console and loads your rails application in it.
1) Could you launch your test using terminal?
2) Does your spec test load rails environment? E.g requires spec_helper which was generated by rspec:install generator.
3) if 1) and 2) ok, please attach full console log from RubyMine run configuration results

0

Please sign in to leave a comment.