重複の可能性:
rspec - assert_equal を使用したこの属性比較は、ubuntu のみで同じ場合に失敗するのはなぜですか?
Ruby: 1.9.3-p194
Rails: 3.2.8
Ubuntu: 12.04
テストには多くのセットアップがあり、最終的には次のようになります。
assert_equal @iep_service.attributes, IepService.first.attributes
Mac では動作しますが、ubuntu では次のように失敗します。
2) Iep Service Spreadsheet A typical district With pre-existing students And a pre-existing Iep Service for one of those students And an Iep S[52/427$
SV Prevent importing
Failure/Error: assert_equal @iep_service.attributes, IepService.first.attributes
MiniTest::Assertion:
<{"id"=>212,
"duration"=>30,
"frequency"=>3,
"period"=>"week",
"group_size"=>"group",
"location"=>nil,
"service"=>nil,
"area_of_need"=>"speech",
"created_at"=>Wed, 24 Oct 2012 18:59:47 UTC +00:00,
"updated_at"=>Wed, 24 Oct 2012 18:59:47 UTC +00:00,
"therapist_id"=>nil,
"start_date"=>nil,
"end_date"=>nil,
"student_id"=>233,
"adhoc"=>false}> expected but was
<{"id"=>212,
"duration"=>30,
"frequency"=>3,
"period"=>"week",
"group_size"=>"group",
"location"=>nil,
"service"=>nil,
"area_of_need"=>"speech",
"created_at"=>Wed, 24 Oct 2012 18:59:47 UTC +00:00,
"updated_at"=>Wed, 24 Oct 2012 18:59:47 UTC +00:00,
"therapist_id"=>nil,
"start_date"=>nil,
"end_date"=>nil,
"student_id"=>233,
"adhoc"=>false}>.
# (eval):2:in `assert_equal'
# ./spec/models/iep_service_spreadsheet_spec.rb:71:in `block (6 levels) in <top (required)>'
それが役立つ場合、完全なソースは次のとおりです。
context "A typical district" do
before(:each) { set_up_district }
context "With pre-existing students" do
before(:each) { StudentSpreadsheet.new(@district, open_spec_fixture_file('sample-students.csv')) }
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.c sv')) }
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
end
end