Ruby on rails 4 未定义的方法为RSpec::ExampleGroups定义枚举
在将rails从4.1升级到4.2.0之后,我得到了方法错误的Ruby on rails 4 未定义的方法为RSpec::ExampleGroups定义枚举,ruby-on-rails-4,shoulda,Ruby On Rails 4,Shoulda,在将rails从4.1升级到4.2.0之后,我得到了方法错误的未定义的define_enum_ 这有什么解决办法吗 Rails:4.2.0 Ruby:Ruby 2.1.5p273(2014-11-13修订版48405)[i686 linux] 1) Recording Failure/Error: should define_enum_for(:state). with({ initial: 'initial',
未定义的define_enum_
这有什么解决办法吗
Rails:4.2.0
Ruby:Ruby 2.1.5p273(2014-11-13修订版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>
1)记录
失败/错误:
应为(:状态)定义_enum_。
与({
首字母:'首字母',
跑步:“跑步”,
停止:“停止”
})
命名错误:
未定义的方法“define_enum_for”#
为shoulda matchers指定
测试框架:rspec
,配置解决了这个问题
所需配置
rails_helper.rb
——但是rails_helper.rb
是我可以放置它的地方(如果可用的话):
元数据
但是,它还需要类型:
元数据才能工作:
This==============\/
describe User, type: :model do
it { should define_enum_for(:status) }
end
# spec/spec_helper.rb
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails # same as :active_record + :active_model + :active_controller
end
end
This==============\/
describe User, type: :model do
it { should define_enum_for(:status) }
end