Search code examples
ruby-on-rails-4shoulda

undefined method define_enum_for for RSpec::ExampleGroups


I am getting undefined define_enum_for method error after upgrading rails to 4.2.0 from 4.1.

Is there any fix for this?

Rails : 4.2.0

Ruby : ruby 2.1.5p273 (2014-11-13 revision 48405) [i686-linux]

  1) Recording 
     Failure/Error:
       should define_enum_for(:state).
         with({
           initial: 'initial',
           running: 'running',
           stopped: 'stopped'
         })

     NoMethodError:
       undefined method `define_enum_for' for #<RSpec::ExampleGroups::Recording:0x99a0ea8>

shoulda-matchers#define_enum_for


Solution

  • specifying the test_framework :rspec for shoulda-matchers#configuration solved this problem.

    shoulda-matchers#configuration

    Shoulda::Matchers.configure do |config|
      config.integrate do |with|
        with.test_framework :rspec
    
        with.library :active_record
        with.library :active_model
        with.library :action_controller
      end
    end