评估其他模型数据时遇到问题
我正在使用 Ruby on Rails 3.0.9 和 RSpec 2。在我的规范文件中,我有如下代码:
describe User do
let(:authorizations) { Authorization.all.map(&:name) }
it "should have a 'registered' value" do
authorizations.should include("registered")
end
end
当我运行上述测试时,我得到:
User should have a 'registered' value
Failure/Error: authorizations.should include("registered")
expected [] to include "registered"
Diff:
@@ -1,2 +1,2 @@
-registered
+[]
是否可以解决上述错误\问题?如果是这样,我该怎么办?
I am using Ruby on Rails 3.0.9 and RSpec 2. In my spec file I have code like the following:
describe User do
let(:authorizations) { Authorization.all.map(&:name) }
it "should have a 'registered' value" do
authorizations.should include("registered")
end
end
When I run the above test I get:
User should have a 'registered' value
Failure/Error: authorizations.should include("registered")
expected [] to include "registered"
Diff:
@@ -1,2 +1,2 @@
-registered
+[]
Is it possible to solve the above error\problem? If so, how can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面的内容告诉我,您的测试数据库中有所有空表。您应该考虑播种 您的开发/测试数据库。 (如果您认为授权是一种查找实体)
或
使用 工厂女孩 在规范的 before 块中为自己创建一些测试数据。
The above tells me that you have you all empty tables in your test database. You should either consider seeding your dev/test databases. (in case your consider Authorization to be a look up kind of entity)
or
using something a factory girl to create some test data for yourself in the before block of your spec.