私は次の工場を持っています:
FactoryGirl.define do
factory :location do |f|
f.descrizione { Faker::Company.name }
f.indirizzo { 'Yellow submarine lane, 1'}
f.citta { 'Nowhereland' }
f.cap { '0100' }
f.provincia { 'ZZ' }
end
end
そして次の仕様:
describe "/api/v1/clients/:client_id/locations.json", :type => :api do
let(:client) { FactoryGirl.create(:client) }
let(:url) { "/api/v1/locations" }
describe 'Locations index' do
it_behaves_like "requires a client"
def do_verb
get url+".json", client_id: client.id
end
describe "fetches all locations for a given client" do
it "returns an empty array of locations when client has no locations" do
do_verb
body = JSON.parse(last_response.body)
body.should eq([])
end
it "returns an array with client's locations" do
location = FactoryGirl.create(:location)
client.locations << location
client.save
do_verb
body = JSON.parse(last_response.body)
location_params = location.attributes
body.should eq([location_params])
end
end
end
...
これで、body の内部にあるものと FactoryGirl (location_params) からのものの :created_at フィールドと :updated_at フィールドの間の比較を除いて、すべてが期待どおりに機能します (しゃれた意図はありません)。
仕様を実行すると返されるエラーは次のとおりです。
Diff:
@@ -5,6 +5,6 @@
"cap"=>"01000",
"citta"=>"Nowhereland",
"provincia"=>"ZZ",
- "created_at"=>Sat, 15 Sep 2012 16:39:13 UTC +00:00,
- "updated_at"=>Sat, 15 Sep 2012 16:39:13 UTC +00:00}]
+ "created_at"=>"2012-09-15T16:39:13Z",
+ "updated_at"=>"2012-09-15T16:39:13Z"}]
ご覧のとおり、応答の created_at と updated_at の両方が、FactoryGirl によって返されるものとは異なる方法で表現されています。
ここで明らかに欠けているのは何ですか?
よろしくお願いいたします。