【发布时间】:2014-08-10 07:16:19
【问题描述】:
我的model 中有一个方法,它返回下面的object,我将其转换为json。
got: "{\"@type\":\"accountResource\",\"createdAt\":\"2014-08-07T14:31:58\",\"createdBy\":2,\"updatedAt\":\"2014-08-07T14:31:58\",\"updatedBy\":2,\"accountid\":2055,\"name\":\"Test\",\"description\":\"Something about Test\",\"disabled\":false}"
我如何将 attributes 单独与我的 stub 进行比较。
以下是我的规格
it "can create an account" do
acc = FactoryGirl.create(:account, name: "Test",
description: "Something about Test");
create_account = Account.create(account: acc)
expect(create_account.to_json).to eq(what)
end
我需要与我的本地 json 进行比较,从 API 返回的 json 与我在本地的 attributes 相同。我不想检查值,只检查 attributes 是否相同。
【问题讨论】:
标签: ruby-on-rails ruby json ruby-on-rails-4 rspec