rspec - warum schlägt dieser Attributvergleich mit assert_equal fehl, wenn sie nur auf Ubuntu identisch sind?

Zwei Tests schlagen fehl - aber nur auf Ubuntu (12), nicht auf meinem (neuen) Mac.

Die beiden Fehler sind Vergleiche von Active Record-Objektattributen, aber bei all meinen Bemühungen, diese zu vergleichen, z. Wenn Sie Hashes in der Befehlszeile erstellen und die Attribute einfügen, wird im Vergleich angegeben, dass sie identisch sind.

Ein echtes Rätsel, da wir eine umfangreiche Testsuite mit vielen hundert Tests haben. Schienen 3.2.8, vgl. 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'

Testcode:

  context "And a pre-existing Iep Service for one of those students" do
    before(:each) { @iep_service = FactoryGirl.create(:iep_service, :student => @district.students.first) }

    context "And an Iep Service CSV" do
      before(:each) { @spreadsheet = IepServiceSpreadsheet.new(@district, open_spec_fixture_file('sample-ieps.csv')) }

      specify "Prevent importing" do
        # Leave database untouched
        assert_equal 1, IepService.count
        assert_equal @iep_service.attributes, IepService.first.attributes

        # Provide error report
        assert @spreadsheet.error_report.any?
      end 
    end 
  end 

Ich habe auch versucht:@iep_service.attributes.should == IepService.first.attributes

aber bekam:

 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 ==)

mit einem großen Unterschied, einschließlich "Überprüfen Sie die Implementierung von":

      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}.==.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage