Hash rspec-为什么只有在ubuntu上,当属性相同时,这个属性比较usng assert_equal失败?

Hash rspec-为什么只有在ubuntu上,当属性相同时,这个属性比较usng assert_equal失败?,hash,rspec,factory-bot,assert,assertions,Hash,Rspec,Factory Bot,Assert,Assertions,有两个测试失败了——但只有在Ubuntu(12)上,而不是在我的(新)Mac上 失败的两个是活动记录对象属性比较,但在我进行比较的所有努力中,例如在命令行进行哈希并将属性粘贴到中,比较表明它们是相同的 一个真正的难题,因为我们有一个包含数百个测试的广泛测试套件。 轨道3.2.8,rspec 2.11 Failure/Error: assert_equal @iep_service.attributes, IepService.first.attributes MiniTest::Asserti

有两个测试失败了——但只有在Ubuntu(12)上,而不是在我的(新)Mac上

失败的两个是活动记录对象属性比较,但在我进行比较的所有努力中,例如在命令行进行哈希并将属性粘贴到中,比较表明它们是相同的

一个真正的难题,因为我们有一个包含数百个测试的广泛测试套件。 轨道3.2.8,rspec 2.11

Failure/Error: assert_equal @iep_service.attributes, IepService.first.attributes
 MiniTest::Assertion:
   <{"id"=>414,
    "duration"=>30,
    "frequency"=>3,
    "period"=>"week",
    "group_size"=>"group",
    "location"=>nil,
    "service"=>nil,
    "area_of_need"=>"speech",
    "created_at"=>Tue, 09 Oct 2012 01:53:39 UTC +00:00,
    "updated_at"=>Tue, 09 Oct 2012 01:53:39 UTC +00:00,
    "therapist_id"=>nil,
    "start_date"=>nil,
    "end_date"=>nil,
    "student_id"=>469,
    "adhoc"=>false}> expected but was
   <{"id"=>414,
    "duration"=>30,
    "frequency"=>3,
    "period"=>"week",
    "group_size"=>"group",
    "location"=>nil,
    "service"=>nil,
    "area_of_need"=>"speech",
    "created_at"=>Tue, 09 Oct 2012 01:53:39 UTC +00:00,
    "updated_at"=>Tue, 09 Oct 2012 01:53:39 UTC +00:00,
    "therapist_id"=>nil,
    "start_date"=>nil,
    "end_date"=>nil,
    "student_id"=>469,
    "adhoc"=>false}>.
# (eval):2:in `assert_equal'
我还尝试了:
@iep\u service.attributes.should==IepService.first.attributes

但是得到:

 Failure/Error: @iep_service.attributes.should == IepService.first.attributes
   expected: {"id"=>421, "duration"=>30, "frequency"=>3, "period"=>"week", "group_size"=>"group", "location"=>nil, "service"=>nil, "area_of_need"=>"speech", "created_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "updated_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "therapist_id"=>nil, "start_date"=>nil, "end_date"=>nil, "student_id"=>483, "adhoc"=>false}
        got: {"id"=>421, "duration"=>30, "frequency"=>3, "period"=>"week", "group_size"=>"group", "location"=>nil, "service"=>nil, "area_of_need"=>"speech", "created_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "updated_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "therapist_id"=>nil, "start_date"=>nil, "end_date"=>nil, "student_id"=>483, "adhoc"=>false} (using ==)
有一个很大的区别,包括“检查”的实现:

      Diff:{"id"=>421, "duration"=>30, "frequency"=>3, "period"=>"week",  
"group_size"=>"group", "location"=>nil, "service"=>nil, "area_of_need"=>"speech",  
"created_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "updated_at"=>Tue, 09 Oct 2012 02:13:51 
UTC +00:00, "therapist_id"=>nil, "start_date"=>nil, "end_date"=>nil, "student_id"=>483, 
"adhoc"=>false}.==({"id"=>421, "duration"=>30, "frequency"=>3, "period"=>"week", 
"group_size"=>"group", "location"=>nil, "service"=>nil, "area_of_need"=>"speech", "created_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "updated_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "therapist_id"=>nil, "start_date"=>nil, "end_date"=>nil, "student_id"=>483, "adhoc"=>false}) returned false even though the diff between {"id"=>421, "duration"=>30, "frequency"=>3, "period"=>"week", "group_size"=>"group", "location"=>nil, "service"=>nil, 
"area_of_need"=>"speech", "created_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, 
"updated_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "therapist_id"=>nil, "start_date"=>nil, 
"end_date"=>nil, "student_id"=>483, "adhoc"=>false} and {"id"=>421, "duration"=>30, 
"frequency"=>3, "period"=>"week", "group_size"=>"group", "location"=>nil, "service"=>nil, 
"area_of_need"=>"speech", "created_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, 
"updated_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, "therapist_id"=>nil, "start_date"=>nil, 
"end_date"=>nil, "student_id"=>483, "adhoc"=>false} is empty. 
Check the implementation of 
{"id"=>421, "duration"=>30, "frequency"=>3, "period"=>"week", "group_size"=>"group", 
"location"=>nil, "service"=>nil, "area_of_need"=>"speech", "created_at"=>Tue, 09 Oct 2012 
02:13:51 UTC +00:00, "updated_at"=>Tue, 09 Oct 2012 02:13:51 UTC +00:00, 
"therapist_id"=>nil, "start_date"=>nil, "end_date"=>nil, "student_id"=>483, 
"adhoc"=>false}.==.

没有给出真正的答案,所以我一直在重复使用atributes,例如

i=0
while i < @student.attributes.count
  assert_equal @student.attributes[i], Student.first.attributes[i]
  i+= 1
end

# Comparing field by field as ruby hash comparison isn't working right - 
# but only on Ubuntu!
i=0
而我<@student.attributes.count
assert_equal@student.attributes[i],student.first.attributes[i]
i+=1
结束
#以ruby哈希比较方式逐个字段进行比较不正常-
#但只在Ubuntu上!

非常奇怪!您尝试过be\u hash\u匹配匹配器吗?
i=0
while i < @student.attributes.count
  assert_equal @student.attributes[i], Student.first.attributes[i]
  i+= 1
end

# Comparing field by field as ruby hash comparison isn't working right - 
# but only on Ubuntu!