【发布时间】:2016-11-22 16:05:29
【问题描述】:
我正在使用 shoulda-matchers 来测试枚举。
describe 'enum' do
it do
should define_enum_for(:gender).
with([:male, :female, :others])
end
end
最近我把DB中的column改为enum数据类型,如图here
我当前在用户模型中的枚举定义。
enum gender: {male:'male', female:'female', others:'others'}
之后,我的测试(显然)失败并显示以下消息。
1) User enum should define :gender as an enum with [:male, :female, :others] and store the value in a column with an integer type
如何使用 rspec 进行测试?
【问题讨论】:
-
你能告诉我们你的枚举是如何在模型中定义的吗?
-
我用模型@Vimsha 的枚举定义更新了我的问题
标签: ruby-on-rails testing rspec-rails