开发者

Trouble on evaluating other model data

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("r开发者_开发知识库egistered")
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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜