spec/lib/shamu/json_api/rails/responder_spec.rb in shamu-0.0.9 vs spec/lib/shamu/json_api/rails/responder_spec.rb in shamu-0.0.11
- old
+ new
@@ -58,35 +58,35 @@
end
end
let( :resource ) { JsonApiResponderSpec::Resource.new( id: 562, name: "Example" ) }
let( :resources ) { [ resource ] }
- let( :body ) { JSON.load( response.body, nil, symbolize_names: true ) }
+ let( :body ) { JSON.parse( response.body, symbolize_names: true ) }
before( :each ) do
allow( controller ).to receive( :_routes ).and_return @routes
allow( controller ).to receive( :resources ).and_return resources
end
describe "#show" do
it "has JSON content_type" do
- get :show, id: 1
+ get :show, params: { id: 1 }
expect( response.content_type ).to eq Shamu::JsonApi::MIME_TYPE
end
it "renders JSON API response" do
- get :show, id: 1
+ get :show, params: { id: 1 }
expect( body ).to include data: hash_including( id: resource.id.to_s )
end
it "renders errors on validation failure" do
errors = ActiveModel::Errors.new( resource )
errors.add :name, "can't be blank"
allow( resource ).to receive( :errors ).and_return errors
allow( resource ).to receive( :valid? ).and_return false
- get :show, id: 1
+ get :show, params: { id: 1 }
expect( body ).to include :errors
end
end
describe "#create" do
@@ -111,26 +111,26 @@
end
end
describe "#update" do
it "has JSON content_type" do
- put :update, id: 1
+ put :update, params: { id: 1 }
expect( response.content_type ).to eq Shamu::JsonApi::MIME_TYPE
end
it "includes location header" do
- post :update, id: 1
+ post :update, params: { id: 1 }
expect( response.location ).to be_present
end
it "returns 200 status code" do
- put :update, id: 1
+ put :update, params: { id: 1 }
expect( response.status ).to eq 200
end
it "includes the json entity" do
- put :update, id: 1
+ put :update, params: { id: 1 }
expect( body ).to include data: hash_including( id: resource.id.to_s )
end
end
describe "#index" do
@@ -148,6 +148,6 @@
get :index
expect( body ).to include data: include( hash_including( id: resource.id.to_s ) )
end
end
-end
\ No newline at end of file
+end