我有以下工厂:
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
...
现在,除了 :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 返回的内容不同。
我显然在这里错过了什么?
在此先感谢您的帮助