…lib/autotest/rails_rspec.rb:38: undefined method `singularize’

Recently I setup up Rspec and Cucumber for an old rails project. When trying to use fixtures in my specs, I came across the following error when running via autotest:

/home/jmacdonald/.rvm/gems/ruby-1.8.7-p302/gems/rspec-rails-1.3.3/lib/autotest/rails_rspec.rb:38: undefined method `singularize' for "users":String (NoMethodError)
        from /home/jmacdonald/.rvm/gems/ruby-1.8.7-p302/gems/ZenTest-4.4.0/lib/autotest.rb:511:in `call'
        from /home/jmacdonald/.rvm/gems/ruby-1.8.7-p302/gems/ZenTest-4.4.0/lib/autotest.rb:511:in `test_files_for'
        from /home/jmacdonald/.rvm/gems/ruby-1.8.7-p302/gems/ZenTest-4.4.0/lib/autotest.rb:383:in `find_files_to_test'...

Requiring ‘active_support/inflector’ to the beginning of the ~/.autotest file seems to ensure that the singularize method is available.

# required to allow rails_rspec.rb to use the rails string singularize method 
require 'active_support/inflector'

Autotest.add_hook :initialize do |autotest|
    %w{.git vendor}.each {|exception| autotest.add_exception(exception) }
end
About these ads
This entry was posted in Web Programming. Bookmark the permalink.

6 Responses to …lib/autotest/rails_rspec.rb:38: undefined method `singularize’

  1. Stefan says:

    you saved my life. Thanks!

  2. Jeff says:

    Helped me, too. Thanks!

  3. Pete. says:

    Good information never gets old. Thanks!

  4. itukano says:

    you also saved the life of Japanese. i love you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s