检查RSpec中的相等性

时间:2013-03-09 23:01:48

标签: ruby caching rspec

我正在测试存储对象以进行缓存。

我正在检查相等性

cached_object.should == original_object

该对象有很多嵌套对象,所以这里只是整个消息的片段:

...
 @e164s=
   -             [#<Mappers::E164:0x000000051c88b0
   +             [#<Mappers::E164:0x0000000525c420
                   @index="1",
                   @value="16508045106">,
   -              #<Mappers::E164:0x000000051c8838
   +              #<Mappers::E164:0x0000000525c358
                   @index="2",
                   @value="17065664321">,
   -              #<Mappers::E164:0x000000051c8720
   +              #<Mappers::E164:0x0000000525c2b8
                   @index="3",
                   @value="12025553356">,
   -              #<Mappers::E164:0x000000051c86a8
   +              #<Mappers::E164:0x0000000525c240
                   @index="4",
                   @value="18185554321">,
   -              #<Mappers::E164:0x000000051c8630
   +              #<Mappers::E164:0x0000000525c1c8
                   @index="5",
                   @value="14085664321">,
   -              #<Mappers::E164:0x000000051c8518
   +              #<Mappers::E164:0x0000000525c128
                   @index="6",
                   @value="16505554321">]
...

如您所见,对象的值相等,但original_object和cached_object中的对象具有不同的object_id&#39;

如何重写测试以使其通过?

0 个答案:

没有答案