Rails3 : solving the issue "undefined method `fixture_path=`"

26 Jul 2012

Some days before when I am writing an application without using ActiveRecord and writing its tests with Rspec, I ran into an error "undefined method `fixture_path=`" when I executes the spec. If you are facing this issue here is how you can fix this error.

I have created this application with -O option for rails command so that it won't use ActiveRecord. I think  rspec-rails is not enough intelligent to know this. When I setup the rspec-rails for Rails 3 it generates a spec/spec_helper.rb with ActiveRecord configurations.

To fix it you need to comment out two lines from spec/spec_helper.rb. In the the gist below 2nd and 7th are the lines to comment.

You can also assign false to config.use_transactional_fixtures instead of commenting. So now your spec/spec_helper.rb will look like this.

Hope it worked for you.
Happy coding.
    If you find my work useful, I appreciate donations via PayPal.
    comments powered by Disqus