spec/acfs/model/query_methods_spec.rb in acfs-0.11.0 vs spec/acfs/model/query_methods_spec.rb in acfs-0.12.0

- old
+ new

@@ -5,13 +5,11 @@ describe '.find' do context 'with single id' do context 'with successful response' do before do - stub_request(:get, 'http://users.example.org/users/1').to_return( - body: MessagePack.dump({ id: 1, name: 'Anon', age: 12 }), - headers: {'Content-Type' => 'application/x-msgpack'}) + stub_request(:get, 'http://users.example.org/users/1').to_return response({ id: 1, name: 'Anon', age: 12 }) end it 'should load a single remote resource' do user = model.find 1 Acfs.run @@ -31,14 +29,11 @@ end end context 'with 404 response' do before do - stub_request(:get, 'http://users.example.org/users/1').to_return( - status: 404, - body: MessagePack.dump({ error: 'not found' }), - headers: {'Content-Type' => 'application/x-msgpack'}) + stub_request(:get, 'http://users.example.org/users/1').to_return response({ error: 'not found' }, status: 404) end it 'should raise a NotFound error' do @user = model.find 1 @@ -48,13 +43,11 @@ end end context 'with 500 response' do before do - stub_request(:get, 'http://users.example.org/users/1').to_return( - status: 500, - headers: {'Content-Type' => 'text/plain'}) + stub_request(:get, 'http://users.example.org/users/1').to_return response(nil, status: 500) end it 'should raise a response error' do @user = model.find 1 @@ -65,16 +58,12 @@ end end context 'with multiple ids' do before do - stub_request(:get, 'http://users.example.org/users/1').to_return( - body: MessagePack.dump({ id: 1, name: 'Anon', age: 12 }), - headers: {'Content-Type' => 'application/x-msgpack'}) - stub_request(:get, 'http://users.example.org/users/2').to_return( - body: MessagePack.dump({ id: 2, name: 'Johnny', age: 42 }), - headers: {'Content-Type' => 'application/x-msgpack'}) + stub_request(:get, 'http://users.example.org/users/1').to_return response({ id: 1, name: 'Anon', age: 12 }) + stub_request(:get, 'http://users.example.org/users/2').to_return response({ id: 2, name: 'Johnny', age: 42 }) end context 'with successful response' do it 'should load a multiple remote resources' do users = model.find 1, 2 @@ -98,13 +87,10 @@ end end context 'with one 404 response' do before do - stub_request(:get, 'http://users.example.org/users/1').to_return( - status: 404, - body: MessagePack.dump({ error: 'not found' }), - headers: {'Content-Type' => 'application/x-msgpack'}) + stub_request(:get, 'http://users.example.org/users/1').to_return response({ error: 'not found' }, status: 404) end it 'should raise resource not found error' do model.find 1, 2