简短的方法应该是respond_to(:attribute)rspec

时间:2012-07-13 10:42:57

标签: ruby-on-rails rspec

在我的rspec测试中,我的模型帖子有很多属性:

it { should respond_to(:title) }
it { should respond_to(:description) }
it { should respond_to(:instruction) }
.
.
.

我可以更准确,在测试中使用更少的行:

it { should respond_to(:title, :description, :instruction) }

1 个答案:

答案 0 :(得分:0)

修复程序位于https://github.com/evansagge/mongoid-rspec

it { should have_fields(:title, :description, :instruction) }

谢谢@Beerlington