Skip to content

Instantly share code, notes, and snippets.

@drale2k
Created August 31, 2012 00:13
Show Gist options
  • Save drale2k/3546119 to your computer and use it in GitHub Desktop.
Save drale2k/3546119 to your computer and use it in GitHub Desktop.
describe Api::V1::DevicesController do
render_views
describe "GET" do
let!(:device) {
@time = Time.now
FactoryGirl.create(:device, pinged_at: @time)
}
describe "/index" do
before { get :index, :format => :json }
it "should work" do
response.status.should be(200)
end
it "should return the device" do
output = JSON.parse(response.body)
output.should == [{
"id" => device.id,
"licence_plate" => device.licence_plate,
"contact_name" => device.contact_name,
"contact_phone" => device.contact_phone,
"pinged_at" => @time.zone.to_time(:local).to_s
}]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment