spree_api 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/base_controller.rb +2 -2
  3. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  4. data/app/controllers/spree/api/shipments_controller.rb +2 -2
  5. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  6. data/app/helpers/spree/api/api_helpers.rb +0 -2
  7. data/app/views/spree/api/shipments/small.v1.rabl +4 -0
  8. data/app/views/spree/api/variants/small.v1.rabl +2 -0
  9. data/lib/spree/api/testing_support/helpers.rb +6 -6
  10. data/lib/spree/api/testing_support/setup.rb +2 -2
  11. data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
  12. data/spec/controllers/spree/api/base_controller_spec.rb +20 -20
  13. data/spec/controllers/spree/api/checkouts_controller_spec.rb +53 -53
  14. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  15. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  16. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  17. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  18. data/spec/controllers/spree/api/images_controller_spec.rb +11 -11
  19. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  20. data/spec/controllers/spree/api/line_items_controller_spec.rb +33 -33
  21. data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
  22. data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
  23. data/spec/controllers/spree/api/orders_controller_spec.rb +170 -132
  24. data/spec/controllers/spree/api/payments_controller_spec.rb +46 -46
  25. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  26. data/spec/controllers/spree/api/products_controller_spec.rb +67 -67
  27. data/spec/controllers/spree/api/promotion_application_spec.rb +11 -11
  28. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  29. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +40 -40
  30. data/spec/controllers/spree/api/shipments_controller_spec.rb +53 -30
  31. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  32. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  33. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  34. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  35. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  36. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  37. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
  38. data/spec/controllers/spree/api/users_controller_spec.rb +25 -25
  39. data/spec/controllers/spree/api/variants_controller_spec.rb +36 -36
  40. data/spec/controllers/spree/api/zones_controller_spec.rb +20 -20
  41. data/spec/models/spree/legacy_user_spec.rb +5 -5
  42. data/spec/requests/rabl_cache_spec.rb +9 -9
  43. data/spec/spec_helper.rb +0 -1
  44. metadata +4 -4
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree::Api
4
- describe OrdersController do
4
+ describe OrdersController, :type => :controller do
5
5
  render_views
6
6
 
7
7
  before do
@@ -19,13 +19,13 @@ module Spree::Api
19
19
  end
20
20
 
21
21
  it "can apply a coupon code to the order" do
22
- order.total.should == 110.00
22
+ expect(order.total).to eq(110.00)
23
23
  api_put :apply_coupon_code, :id => order.to_param, :coupon_code => "10off", :order_token => order.guest_token
24
- response.status.should == 200
25
- order.reload.total.should == 109.00
26
- json_response["success"].should == "The coupon code was successfully applied to your order."
27
- json_response["error"].should be_blank
28
- json_response["successful"].should be true
24
+ expect(response.status).to eq(200)
25
+ expect(order.reload.total).to eq(109.00)
26
+ expect(json_response["success"]).to eq("The coupon code was successfully applied to your order.")
27
+ expect(json_response["error"]).to be_blank
28
+ expect(json_response["successful"]).to be true
29
29
  end
30
30
 
31
31
  context "with an expired promotion" do
@@ -37,10 +37,10 @@ module Spree::Api
37
37
 
38
38
  it "fails to apply" do
39
39
  api_put :apply_coupon_code, :id => order.to_param, :coupon_code => "10off", :order_token => order.guest_token
40
- response.status.should == 422
41
- json_response["success"].should be_blank
42
- json_response["error"].should == "The coupon code is expired"
43
- json_response["successful"].should be false
40
+ expect(response.status).to eq(422)
41
+ expect(json_response["success"]).to be_blank
42
+ expect(json_response["error"]).to eq("The coupon code is expired")
43
+ expect(json_response["successful"]).to be false
44
44
  end
45
45
  end
46
46
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  module Spree
3
- describe Spree::Api::PropertiesController do
3
+ describe Spree::Api::PropertiesController, :type => :controller do
4
4
  render_views
5
5
 
6
6
  let!(:property_1) { Property.create!(:name => "foo", :presentation => "Foo") }
@@ -14,50 +14,50 @@ module Spree
14
14
 
15
15
  it "can see a list of all properties" do
16
16
  api_get :index
17
- json_response["properties"].count.should eq(2)
18
- json_response["properties"].first.should have_attributes(attributes)
17
+ expect(json_response["properties"].count).to eq(2)
18
+ expect(json_response["properties"].first).to have_attributes(attributes)
19
19
  end
20
20
 
21
21
  it "can control the page size through a parameter" do
22
22
  api_get :index, :per_page => 1
23
- json_response['properties'].count.should == 1
24
- json_response['current_page'].should == 1
25
- json_response['pages'].should == 2
23
+ expect(json_response['properties'].count).to eq(1)
24
+ expect(json_response['current_page']).to eq(1)
25
+ expect(json_response['pages']).to eq(2)
26
26
  end
27
27
 
28
28
  it 'can query the results through a parameter' do
29
29
  api_get :index, :q => { :name_cont => 'ba' }
30
- json_response['count'].should == 1
31
- json_response['properties'].first['presentation'].should eq property_2.presentation
30
+ expect(json_response['count']).to eq(1)
31
+ expect(json_response['properties'].first['presentation']).to eq property_2.presentation
32
32
  end
33
33
 
34
34
  it "retrieves a list of properties by id" do
35
35
  api_get :index, :ids => [property_1.id]
36
- json_response["properties"].first.should have_attributes(attributes)
37
- json_response["count"].should == 1
36
+ expect(json_response["properties"].first).to have_attributes(attributes)
37
+ expect(json_response["count"]).to eq(1)
38
38
  end
39
39
 
40
40
  it "retrieves a list of properties by ids string" do
41
41
  api_get :index, :ids => [property_1.id, property_2.id].join(",")
42
- json_response["properties"].first.should have_attributes(attributes)
43
- json_response["properties"][1].should have_attributes(attributes)
44
- json_response["count"].should == 2
42
+ expect(json_response["properties"].first).to have_attributes(attributes)
43
+ expect(json_response["properties"][1]).to have_attributes(attributes)
44
+ expect(json_response["count"]).to eq(2)
45
45
  end
46
46
 
47
47
  it "can see a single property" do
48
48
  api_get :show, :id => property_1.id
49
- json_response.should have_attributes(attributes)
49
+ expect(json_response).to have_attributes(attributes)
50
50
  end
51
51
 
52
52
  it "can see a property by name" do
53
53
  api_get :show, :id => property_1.name
54
- json_response.should have_attributes(attributes)
54
+ expect(json_response).to have_attributes(attributes)
55
55
  end
56
56
 
57
57
  it "can learn how to create a new property" do
58
58
  api_get :new
59
- json_response["attributes"].should == attributes.map(&:to_s)
60
- json_response["required_attributes"].should be_empty
59
+ expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
60
+ expect(json_response["required_attributes"]).to be_empty
61
61
  end
62
62
 
63
63
  it "cannot create a new property if not an admin" do
@@ -73,29 +73,29 @@ module Spree
73
73
  it "cannot delete a property" do
74
74
  api_delete :destroy, :id => property_1.id
75
75
  assert_unauthorized!
76
- lambda { property_1.reload }.should_not raise_error
76
+ expect { property_1.reload }.not_to raise_error
77
77
  end
78
78
 
79
79
  context "as an admin" do
80
80
  sign_in_as_admin!
81
81
 
82
82
  it "can create a new property" do
83
- Spree::Property.count.should == 2
83
+ expect(Spree::Property.count).to eq(2)
84
84
  api_post :create, :property => { :name => "My Property 3", :presentation => "my value 3" }
85
- json_response.should have_attributes(attributes)
86
- response.status.should == 201
87
- Spree::Property.count.should == 3
85
+ expect(json_response).to have_attributes(attributes)
86
+ expect(response.status).to eq(201)
87
+ expect(Spree::Property.count).to eq(3)
88
88
  end
89
89
 
90
90
  it "can update a property" do
91
91
  api_put :update, :id => property_1.name, :property => { :presentation => "my value 456" }
92
- response.status.should == 200
92
+ expect(response.status).to eq(200)
93
93
  end
94
94
 
95
95
  it "can delete a property" do
96
96
  api_delete :destroy, :id => property_1.name
97
- response.status.should == 204
98
- lambda { property_1.reload }.should raise_error(ActiveRecord::RecordNotFound)
97
+ expect(response.status).to eq(204)
98
+ expect { property_1.reload }.to raise_error(ActiveRecord::RecordNotFound)
99
99
  end
100
100
  end
101
101
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::ReturnAuthorizationsController do
4
+ describe Api::ReturnAuthorizationsController, :type => :controller do
5
5
  render_views
6
6
 
7
7
  let!(:order) { create(:shipped_order) }
@@ -16,7 +16,7 @@ module Spree
16
16
 
17
17
  context "as the order owner" do
18
18
  before do
19
- Order.any_instance.stub :user => current_api_user
19
+ allow_any_instance_of(Order).to receive_messages :user => current_api_user
20
20
  end
21
21
 
22
22
  it "cannot see any return authorizations" do
@@ -57,28 +57,28 @@ module Spree
57
57
  FactoryGirl.create(:return_authorization, :order => order)
58
58
  return_authorization = order.return_authorizations.first
59
59
  api_get :show, :order_id => order.number, :id => return_authorization.id
60
- response.status.should == 200
61
- json_response.should have_attributes(attributes)
62
- json_response["state"].should_not be_blank
60
+ expect(response.status).to eq(200)
61
+ expect(json_response).to have_attributes(attributes)
62
+ expect(json_response["state"]).not_to be_blank
63
63
  end
64
64
 
65
65
  it "can get a list of return authorizations" do
66
66
  FactoryGirl.create(:return_authorization, :order => order)
67
67
  FactoryGirl.create(:return_authorization, :order => order)
68
68
  api_get :index, { :order_id => order.number }
69
- response.status.should == 200
69
+ expect(response.status).to eq(200)
70
70
  return_authorizations = json_response["return_authorizations"]
71
- return_authorizations.first.should have_attributes(attributes)
72
- return_authorizations.first.should_not == return_authorizations.last
71
+ expect(return_authorizations.first).to have_attributes(attributes)
72
+ expect(return_authorizations.first).not_to eq(return_authorizations.last)
73
73
  end
74
74
 
75
75
  it 'can control the page size through a parameter' do
76
76
  FactoryGirl.create(:return_authorization, :order => order)
77
77
  FactoryGirl.create(:return_authorization, :order => order)
78
78
  api_get :index, :order_id => order.number, :per_page => 1
79
- json_response['count'].should == 1
80
- json_response['current_page'].should == 1
81
- json_response['pages'].should == 2
79
+ expect(json_response['count']).to eq(1)
80
+ expect(json_response['current_page']).to eq(1)
81
+ expect(json_response['pages']).to eq(2)
82
82
  end
83
83
 
84
84
  it 'can query the results through a paramter' do
@@ -86,85 +86,85 @@ module Spree
86
86
  expected_result = create(:return_authorization, :reason => 'damaged')
87
87
  order.return_authorizations << expected_result
88
88
  api_get :index, :q => { :reason_cont => 'damage' }
89
- json_response['count'].should == 1
90
- json_response['return_authorizations'].first['reason'].should eq expected_result.reason
89
+ expect(json_response['count']).to eq(1)
90
+ expect(json_response['return_authorizations'].first['reason']).to eq expected_result.reason
91
91
  end
92
92
 
93
93
  it "can learn how to create a new return authorization" do
94
94
  api_get :new
95
- json_response["attributes"].should == ["id", "number", "state", "amount", "order_id", "reason", "created_at", "updated_at"]
95
+ expect(json_response["attributes"]).to eq(["id", "number", "state", "amount", "order_id", "reason", "created_at", "updated_at"])
96
96
  required_attributes = json_response["required_attributes"]
97
- required_attributes.should include("order")
97
+ expect(required_attributes).to include("order")
98
98
  end
99
99
 
100
100
  it "can update a return authorization on the order" do
101
101
  FactoryGirl.create(:return_authorization, :order => order)
102
102
  return_authorization = order.return_authorizations.first
103
103
  api_put :update, :id => return_authorization.id, :return_authorization => { :amount => 19.99 }
104
- response.status.should == 200
105
- json_response.should have_attributes(attributes)
104
+ expect(response.status).to eq(200)
105
+ expect(json_response).to have_attributes(attributes)
106
106
  end
107
107
 
108
108
  it "can add an inventory unit to a return authorization on the order" do
109
109
  FactoryGirl.create(:return_authorization, :order => order)
110
110
  return_authorization = order.return_authorizations.first
111
111
  inventory_unit = return_authorization.returnable_inventory.first
112
- inventory_unit.should be
113
- return_authorization.inventory_units.should be_empty
112
+ expect(inventory_unit).to be
113
+ expect(return_authorization.inventory_units).to be_empty
114
114
  api_put :add, :id => return_authorization.id, variant_id: inventory_unit.variant.id, quantity: 1
115
- response.status.should == 200
116
- json_response.should have_attributes(attributes)
117
- return_authorization.reload.inventory_units.should_not be_empty
115
+ expect(response.status).to eq(200)
116
+ expect(json_response).to have_attributes(attributes)
117
+ expect(return_authorization.reload.inventory_units).not_to be_empty
118
118
  end
119
119
 
120
120
  it "can mark a return authorization as received on the order with an inventory unit" do
121
121
  FactoryGirl.create(:new_return_authorization, :order => order, :stock_location_id => order.shipments.first.stock_location.id)
122
122
  return_authorization = order.return_authorizations.first
123
- return_authorization.state.should == "authorized"
123
+ expect(return_authorization.state).to eq("authorized")
124
124
 
125
125
  # prep (use a rspec context or a factory instead?)
126
126
  inventory_unit = return_authorization.returnable_inventory.first
127
- inventory_unit.should be
128
- return_authorization.inventory_units.should be_empty
127
+ expect(inventory_unit).to be
128
+ expect(return_authorization.inventory_units).to be_empty
129
129
  api_put :add, :id => return_authorization.id, variant_id: inventory_unit.variant.id, quantity: 1
130
130
  # end prep
131
131
 
132
132
  api_delete :receive, :id => return_authorization.id
133
- response.status.should == 200
134
- return_authorization.reload.state.should == "received"
133
+ expect(response.status).to eq(200)
134
+ expect(return_authorization.reload.state).to eq("received")
135
135
  end
136
136
 
137
137
  it "cannot mark a return authorization as received on the order with no inventory units" do
138
138
  FactoryGirl.create(:new_return_authorization, :order => order)
139
139
  return_authorization = order.return_authorizations.first
140
- return_authorization.state.should == "authorized"
140
+ expect(return_authorization.state).to eq("authorized")
141
141
  api_delete :receive, :id => return_authorization.id
142
- response.status.should == 422
143
- return_authorization.reload.state.should == "authorized"
142
+ expect(response.status).to eq(422)
143
+ expect(return_authorization.reload.state).to eq("authorized")
144
144
  end
145
145
 
146
146
  it "can cancel a return authorization on the order" do
147
147
  FactoryGirl.create(:new_return_authorization, :order => order)
148
148
  return_authorization = order.return_authorizations.first
149
- return_authorization.state.should == "authorized"
149
+ expect(return_authorization.state).to eq("authorized")
150
150
  api_delete :cancel, :id => return_authorization.id
151
- response.status.should == 200
152
- return_authorization.reload.state.should == "canceled"
151
+ expect(response.status).to eq(200)
152
+ expect(return_authorization.reload.state).to eq("canceled")
153
153
  end
154
154
 
155
155
  it "can delete a return authorization on the order" do
156
156
  FactoryGirl.create(:return_authorization, :order => order)
157
157
  return_authorization = order.return_authorizations.first
158
158
  api_delete :destroy, :id => return_authorization.id
159
- response.status.should == 204
160
- lambda { return_authorization.reload }.should raise_error(ActiveRecord::RecordNotFound)
159
+ expect(response.status).to eq(204)
160
+ expect { return_authorization.reload }.to raise_error(ActiveRecord::RecordNotFound)
161
161
  end
162
162
 
163
163
  it "can add a new return authorization to an existing order" do
164
164
  api_post :create, :order_id => order.number, :return_authorization => { :amount => 14.22, :reason => "Defective" }
165
- response.status.should == 201
166
- json_response.should have_attributes(attributes)
167
- json_response["state"].should_not be_blank
165
+ expect(response.status).to eq(201)
166
+ expect(json_response).to have_attributes(attributes)
167
+ expect(json_response["state"]).not_to be_blank
168
168
  end
169
169
  end
170
170
 
@@ -179,7 +179,7 @@ module Spree
179
179
  return_authorization = order.return_authorizations.first
180
180
  api_put :update, :id => return_authorization.id, :return_authorization => { :amount => 19.99 }
181
181
  assert_unauthorized!
182
- return_authorization.reload.amount.should_not == 19.99
182
+ expect(return_authorization.reload.amount).not_to eq(19.99)
183
183
  end
184
184
 
185
185
  it "cannot delete a return authorization on the order" do
@@ -187,7 +187,7 @@ module Spree
187
187
  return_authorization = order.return_authorizations.first
188
188
  api_delete :destroy, :id => return_authorization.id
189
189
  assert_unauthorized!
190
- lambda { return_authorization.reload }.should_not raise_error
190
+ expect { return_authorization.reload }.not_to raise_error
191
191
  end
192
192
  end
193
193
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::Api::ShipmentsController do
3
+ describe Spree::Api::ShipmentsController, :type => :controller do
4
4
  render_views
5
5
  let!(:shipment) { create(:shipment) }
6
6
  let!(:attributes) { [:id, :tracking, :number, :cost, :shipped_at, :stock_location_name, :order_id, :shipping_rates, :shipping_methods] }
@@ -27,18 +27,41 @@ describe Spree::Api::ShipmentsController do
27
27
  let!(:order) { shipment.order }
28
28
  let!(:stock_location) { create(:stock_location_with_items) }
29
29
  let!(:variant) { create(:variant) }
30
+
30
31
  sign_in_as_admin!
31
32
 
32
- it 'can create a new shipment' do
33
- params = {
34
- variant_id: stock_location.stock_items.first.variant.to_param,
35
- shipment: { order_id: order.number },
36
- stock_location_id: stock_location.to_param,
37
- }
33
+ # Start writing this spec a bit differently than before....
34
+ describe 'POST #create' do
35
+ let(:params) do
36
+ {
37
+ variant_id: stock_location.stock_items.first.variant.to_param,
38
+ shipment: { order_id: order.number },
39
+ stock_location_id: stock_location.to_param
40
+ }
41
+ end
42
+
43
+ subject do
44
+ api_post :create, params
45
+ end
46
+
47
+ [:variant_id, :stock_location_id].each do |field|
48
+ context "when #{field} is missing" do
49
+ before do
50
+ params.delete(field)
51
+ end
52
+
53
+ it 'should return proper error' do
54
+ subject
55
+ expect(response.status).to eq(422)
56
+ expect(json_response['exception']).to eq("param is missing or the value is empty: #{field.to_s}")
57
+ end
58
+ end
59
+ end
38
60
 
39
- api_post :create, params
40
- response.status.should == 200
41
- json_response.should have_attributes(attributes)
61
+ it 'should create a new shipment' do
62
+ expect(subject).to be_ok
63
+ expect(json_response).to have_attributes(attributes)
64
+ end
42
65
  end
43
66
 
44
67
  it 'can update a shipment' do
@@ -49,23 +72,23 @@ describe Spree::Api::ShipmentsController do
49
72
  }
50
73
 
51
74
  api_put :update, params
52
- response.status.should == 200
53
- json_response['stock_location_name'].should == stock_location.name
75
+ expect(response.status).to eq(200)
76
+ expect(json_response['stock_location_name']).to eq(stock_location.name)
54
77
  end
55
78
 
56
79
  it "can make a shipment ready" do
57
- Spree::Order.any_instance.stub(:paid? => true, :complete? => true)
80
+ allow_any_instance_of(Spree::Order).to receive_messages(:paid? => true, :complete? => true)
58
81
  api_put :ready
59
- json_response.should have_attributes(attributes)
60
- json_response["state"].should == "ready"
61
- shipment.reload.state.should == "ready"
82
+ expect(json_response).to have_attributes(attributes)
83
+ expect(json_response["state"]).to eq("ready")
84
+ expect(shipment.reload.state).to eq("ready")
62
85
  end
63
86
 
64
87
  it "cannot make a shipment ready if the order is unpaid" do
65
- Spree::Order.any_instance.stub(:paid? => false)
88
+ allow_any_instance_of(Spree::Order).to receive_messages(:paid? => false)
66
89
  api_put :ready
67
- json_response["error"].should == "Cannot ready shipment."
68
- response.status.should == 422
90
+ expect(json_response["error"]).to eq("Cannot ready shipment.")
91
+ expect(response.status).to eq(422)
69
92
  end
70
93
 
71
94
  context 'for completed shipments' do
@@ -74,16 +97,16 @@ describe Spree::Api::ShipmentsController do
74
97
 
75
98
  it 'adds a variant to a shipment' do
76
99
  api_put :add, { variant_id: variant.to_param, quantity: 2 }
77
- response.status.should == 200
78
- json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"].should == 2
100
+ expect(response.status).to eq(200)
101
+ expect(json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"]).to eq(2)
79
102
  end
80
103
 
81
104
  it 'removes a variant from a shipment' do
82
105
  order.contents.add(variant, 2)
83
106
 
84
107
  api_put :remove, { variant_id: variant.to_param, quantity: 1 }
85
- response.status.should == 200
86
- json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"].should == 1
108
+ expect(response.status).to eq(200)
109
+ expect(json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"]).to eq(1)
87
110
  end
88
111
 
89
112
  it 'removes a destroyed variant from a shipment' do
@@ -91,27 +114,27 @@ describe Spree::Api::ShipmentsController do
91
114
  variant.destroy
92
115
 
93
116
  api_put :remove, { variant_id: variant.to_param, quantity: 1 }
94
- response.status.should == 200
95
- json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"].should == 1
117
+ expect(response.status).to eq(200)
118
+ expect(json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"]).to eq(1)
96
119
  end
97
120
  end
98
121
 
99
122
  context "can transition a shipment from ready to ship" do
100
123
  before do
101
- Spree::Order.any_instance.stub(:paid? => true, :complete? => true)
124
+ allow_any_instance_of(Spree::Order).to receive_messages(:paid? => true, :complete? => true)
102
125
  # For the shipment notification email
103
126
  Spree::Config[:mails_from] = "spree@example.com"
104
127
 
105
128
  shipment.update!(shipment.order)
106
- shipment.state.should == "ready"
107
- Spree::ShippingRate.any_instance.stub(:cost => 5)
129
+ expect(shipment.state).to eq("ready")
130
+ allow_any_instance_of(Spree::ShippingRate).to receive_messages(:cost => 5)
108
131
  end
109
132
 
110
133
  it "can transition a shipment from ready to ship" do
111
134
  shipment.reload
112
135
  api_put :ship, id: shipment.to_param, shipment: { tracking: "123123", order_id: shipment.order.to_param }
113
- json_response.should have_attributes(attributes)
114
- json_response["state"].should == "shipped"
136
+ expect(json_response).to have_attributes(attributes)
137
+ expect(json_response["state"]).to eq("shipped")
115
138
  end
116
139
 
117
140
  end