spec/shipcloud/address_spec.rb in shipcloud-0.6.0 vs spec/shipcloud/address_spec.rb in shipcloud-0.7.0

- old
+ new

@@ -33,35 +33,39 @@ end end describe '.create' do it 'makes a new POST request using the correct API endpoint' do - Shipcloud.should_receive(:request).with(:post, 'addresses', valid_attributes).and_return('data' => {}) + expect(Shipcloud).to receive(:request). + with(:post, "addresses", valid_attributes, api_key: nil).and_return("data" => {}) + Shipcloud::Address.create(valid_attributes) end end describe '.find' do it 'makes a new GET request using the correct API endpoint to receive a specific address' do - Shipcloud.should_receive(:request).with( - :get, 'addresses/123', {}).and_return('id' => '123') - Shipcloud::Address.find('123') + expect(Shipcloud).to receive(:request).with( + :get, "addresses/123", {}, api_key: nil).and_return("id" => "123") + + Shipcloud::Address.find("123") end end describe '.update' do it 'makes a new PUT request using the correct API endpoint' do - Shipcloud.should_receive(:request).with( - :put, 'addresses/123', {:street => 'Mittelweg' }).and_return('data' => {}) - Shipcloud::Address.update('123', {:street => 'Mittelweg' }) + expect(Shipcloud).to receive(:request).with( + :put, "addresses/123", { street: "Mittelweg" }, api_key: nil).and_return("data" => {}) + + Shipcloud::Address.update("123", street: "Mittelweg") end end describe '.all' do it 'makes a new Get request using the correct API endpoint' do expect(Shipcloud).to receive(:request). - with(:get, 'addresses', {}).and_return([]) + with(:get, "addresses", {}, api_key: nil).and_return([]) Shipcloud::Address.all end it 'returns a list of Address objects' do @@ -75,40 +79,40 @@ end end def stub_addresses_request allow(Shipcloud).to receive(:request). - with(:get, 'addresses', {}). - and_return( - [ - { - 'id' => '1c81efb7-9b95-4dd8-92e3-cac1bca3df6f', - 'company' => '', - 'first_name' => 'Max', - 'last_name' => 'Mustermann', - 'care_of' => '', - 'street' => 'Musterstraße', - 'street_no' => '42', - 'zip_code' => '12345', - 'city' => 'Musterstadt', - 'state' => '', - 'country' => 'DE', - 'phone' => '' - }, - { - 'id' => '7ea2a290-b456-4ecf-9010-e82b3da298f0', - 'company' => 'Muster-Company', - 'first_name' => 'Max', - 'last_name' => 'Mustermann', - 'care_of' => '', - 'street' => 'Musterstraße', - 'street_no' => '42', - 'zip_code' => '54321', - 'city' => 'Musterstadt', - 'state' => '', - 'country' => 'DE', - 'phone' => '' - } - ] - ) + with(:get, "addresses", {}, api_key: nil). + and_return( + [ + { + "id" => "1c81efb7-9b95-4dd8-92e3-cac1bca3df6f", + "company" => "", + "first_name" => "Max", + "last_name" => "Mustermann", + "care_of" => "", + "street" => "Musterstraße", + "street_no" => "42", + "zip_code" => "12345", + "city" => "Musterstadt", + "state" => "", + "country" => "DE", + "phone" => "" + }, + { + "id" => "7ea2a290-b456-4ecf-9010-e82b3da298f0", + "company" => "Muster-Company", + "first_name" => "Max", + "last_name" => "Mustermann", + "care_of" => "", + "street" => "Musterstraße", + "street_no" => "42", + "zip_code" => "54321", + "city" => "Musterstadt", + "state" => "", + "country" => "DE", + "phone" => "" + } + ] + ) end end