RSPEC对象验证失败...在`:
我已经写了一个测试,看起来很接近,但不是很正确。
it "adds the correct permissions" do
subject
expect(policy.permissions).to have_key("users")
expect(policy.permissions["users"]).to eq({ "all_users" => {
can_view: false,
can_manage: false,
} })
end
输出:
expected: {"all_users"=>{:can_manage=>false, :can_view=>false}}
got: {"all_users"=>{"can_manage"=>false, "can_view"=>false}}
显然我很接近,但是我不确定的交易是什么:
符号与“ got” got“ got”
输出。我该如何通过?
I've written a test and it seems so close but not quite right.
it "adds the correct permissions" do
subject
expect(policy.permissions).to have_key("users")
expect(policy.permissions["users"]).to eq({ "all_users" => {
can_view: false,
can_manage: false,
} })
end
Output:
expected: {"all_users"=>{:can_manage=>false, :can_view=>false}}
got: {"all_users"=>{"can_manage"=>false, "can_view"=>false}}
Obviously I'm close but I'm not sure what the deal is in terms of the :
notation versus the "got"
output from the test itself. How do I get this to pass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字符串键在哈希类中不等于符号键。这是以下示例代码:
因此,您应该期望这样的结果:
String keys are not equal to symbol keys in Hash class. Here is the example code below:
so you should expect the result like this: