我有一个规范,当我调用all方法时,我将获得如下所示的Account对象。
得到:#“accountResource”, :createdAt =>“2014-08-12T09:50:02.031”,:createdBy => 2, :updatedAt =>“2014-08-12T09:50:02.135”,:updatedBy => 2, :accountid => 2547,:name =>“account1”,:description =>“Something about about account1“,:disabled => false},@ dirty_attributes =#>]>
以下是我的规格。
it "should get all accounts" do
acc = Account.all({auth: @token});
expect(acc) to eq(what)
end
我需要检查我的方法是否返回有效结果。我的帐户可以期待什么?。
答案 0 :(得分:2)
试试这个
it "should get all accounts" do
acc = Account.all({auth: @token});
expect(acc) to be_an(Array)
expect(acc.first.class) to eq(Account)
end
答案 1 :(得分:1)
您不应该检查实例是否等于另一个对象。您应该检查对象属性:
it "should get all accounts" do
acc = Account.all({auth: @token});
expect(acc.name) to eq("account1")
expect(acc.description) to eq("Something about account1")
end
..等等!