Skip to content

Commit a65ff6e

Browse files
committed
Features use new expect() syntax
1 parent d818afe commit a65ff6e

22 files changed

+154
-137
lines changed

features/controller_specs/anonymous_controller.feature

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Feature: anonymous controller
4646
describe "handling AccessDenied exceptions" do
4747
it "redirects to the /401.html page" do
4848
get :index
49-
response.should redirect_to("/401.html")
49+
expect(response).to redirect_to("/401.html")
5050
end
5151
end
5252
end
@@ -84,7 +84,7 @@ Feature: anonymous controller
8484
describe "handling AccessDenied exceptions" do
8585
it "redirects to the /401.html page" do
8686
get :index
87-
response.should redirect_to("/401.html")
87+
expect(response).to redirect_to("/401.html")
8888
end
8989
end
9090
end
@@ -113,7 +113,7 @@ Feature: anonymous controller
113113
end
114114
115115
it "creates an anonymous controller derived from ApplicationControllerSubclass" do
116-
controller.should be_a_kind_of(ApplicationControllerSubclass)
116+
expect(controller).to be_a_kind_of(ApplicationControllerSubclass)
117117
end
118118
end
119119
"""
@@ -144,7 +144,7 @@ Feature: anonymous controller
144144
it "invokes the callback" do
145145
get :index
146146
147-
assigns[:callback_invoked].should be_true
147+
expect(assigns[:callback_invoked]).to be_true
148148
end
149149
end
150150
"""
@@ -194,59 +194,59 @@ Feature: anonymous controller
194194
describe "#index" do
195195
it "responds to GET" do
196196
get :index
197-
response.body.should == "index called"
197+
expect(response.body).to eq "index called"
198198
end
199199
200200
it "also responds to POST" do
201201
post :index
202-
response.body.should == "index called"
202+
expect(response.body).to eq "index called"
203203
end
204204
205205
it "also responds to PUT" do
206206
put :index
207-
response.body.should == "index called"
207+
expect(response.body).to eq "index called"
208208
end
209209
210210
it "also responds to DELETE" do
211211
delete :index
212-
response.body.should == "index called"
212+
expect(response.body).to eq "index called"
213213
end
214214
end
215215
216216
describe "#create" do
217217
it "responds to POST" do
218218
post :create
219-
response.body.should == "create called"
219+
expect(response.body).to eq "create called"
220220
end
221221
222222
# And the rest...
223223
%w{get post put delete}.each do |calltype|
224224
it "responds to #{calltype}" do
225225
send(calltype, :create)
226-
response.body.should == "create called"
226+
expect(response.body).to eq "create called"
227227
end
228228
end
229229
end
230230
231231
describe "#new" do
232232
it "responds to GET" do
233233
get :new
234-
response.body.should == "new called"
234+
expect(response.body).to eq "new called"
235235
end
236236
237237
# And the rest...
238238
%w{get post put delete}.each do |calltype|
239239
it "responds to #{calltype}" do
240240
send(calltype, :new)
241-
response.body.should == "new called"
241+
expect(response.body).to eq "new called"
242242
end
243243
end
244244
end
245245
246246
describe "#edit" do
247247
it "responds to GET" do
248248
get :edit, :id => "anyid"
249-
response.body.should == "edit called"
249+
expect(response.body).to eq "edit called"
250250
end
251251
252252
it "requires the :id parameter" do
@@ -257,15 +257,15 @@ Feature: anonymous controller
257257
%w{get post put delete}.each do |calltype|
258258
it "responds to #{calltype}" do
259259
send(calltype, :edit, {:id => "anyid"})
260-
response.body.should == "edit called"
260+
expect(response.body).to eq "edit called"
261261
end
262262
end
263263
end
264264
265265
describe "#show" do
266266
it "responds to GET" do
267267
get :show, :id => "anyid"
268-
response.body.should == "show called"
268+
expect(response.body).to eq "show called"
269269
end
270270
271271
it "requires the :id parameter" do
@@ -276,15 +276,15 @@ Feature: anonymous controller
276276
%w{get post put delete}.each do |calltype|
277277
it "responds to #{calltype}" do
278278
send(calltype, :show, {:id => "anyid"})
279-
response.body.should == "show called"
279+
expect(response.body).to eq "show called"
280280
end
281281
end
282282
end
283283
284284
describe "#update" do
285285
it "responds to PUT" do
286286
put :update, :id => "anyid"
287-
response.body.should == "update called"
287+
expect(response.body).to eq "update called"
288288
end
289289
290290
it "requires the :id parameter" do
@@ -295,15 +295,15 @@ Feature: anonymous controller
295295
%w{get post put delete}.each do |calltype|
296296
it "responds to #{calltype}" do
297297
send(calltype, :update, {:id => "anyid"})
298-
response.body.should == "update called"
298+
expect(response.body).to eq "update called"
299299
end
300300
end
301301
end
302302
303303
describe "#destroy" do
304304
it "responds to DELETE" do
305305
delete :destroy, :id => "anyid"
306-
response.body.should == "destroy called"
306+
expect(response.body).to eq "destroy called"
307307
end
308308
309309
it "requires the :id parameter" do
@@ -314,7 +314,7 @@ Feature: anonymous controller
314314
%w{get post put delete}.each do |calltype|
315315
it "responds to #{calltype}" do
316316
send(calltype, :destroy, {:id => "anyid"})
317-
response.body.should == "destroy called"
317+
expect(response.body).to eq "destroy called"
318318
end
319319
end
320320
end

features/controller_specs/bypass_rescue.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Feature: bypass rescue
4040
describe "index" do
4141
it "redirects to the /401.html page" do
4242
get :index
43-
response.should redirect_to("/401.html")
43+
expect(response).to redirect_to("/401.html")
4444
end
4545
end
4646
end

features/controller_specs/controller_spec.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: controller spec
99
describe "GET index" do
1010
it "has a 200 status code" do
1111
get :index
12-
response.code.should eq("200")
12+
expect(response.code).to eq("200")
1313
end
1414
end
1515
end
@@ -22,7 +22,7 @@ Feature: controller spec
2222
"""
2323
require "spec_helper"
2424
25-
RSpec.configure {|c| c.before { controller.should_not be_nil }}
25+
RSpec.configure {|c| c.before { expect(controller).not_to be_nil }}
2626
2727
describe WidgetsController do
2828
describe "GET index" do

features/controller_specs/isolation_from_views.feature

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Feature: views are stubbed by default
1616
describe "index" do
1717
it "renders the index template" do
1818
get :index
19-
response.should render_template("index")
20-
response.body.should eq ""
19+
expect(response).to render_template("index")
20+
expect(response.body).to eq ""
2121
end
2222
it "renders the widgets/index template" do
2323
get :index
24-
response.should render_template("widgets/index")
25-
response.body.should eq ""
24+
expect(response).to render_template("widgets/index")
25+
expect(response.body).to eq ""
2626
end
2727
end
2828
end
@@ -39,7 +39,7 @@ Feature: views are stubbed by default
3939
describe "index" do
4040
it "renders the 'new' template" do
4141
get :index
42-
response.should render_template("new")
42+
expect(response).to render_template("new")
4343
end
4444
end
4545
end
@@ -58,8 +58,8 @@ Feature: views are stubbed by default
5858
controller.prepend_view_path 'app/views'
5959
controller.append_view_path 'app/views'
6060
get :custom_action
61-
response.should render_template("custom_action")
62-
response.body.should eq ""
61+
expect(response).to render_template("custom_action")
62+
expect(response.body).to eq ""
6363
end
6464
end
6565
end
@@ -78,8 +78,8 @@ Feature: views are stubbed by default
7878
it "renders the real custom_action template" do
7979
controller.prepend_view_path 'app/views'
8080
get :custom_action
81-
response.should render_template("custom_action")
82-
response.body.should match(/template for a custom action/)
81+
expect(response).to render_template("custom_action")
82+
expect(response.body).to match(/template for a custom action/)
8383
end
8484
end
8585
"""

features/controller_specs/render_views.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Feature: render_views
1414
describe "GET index" do
1515
it "says 'Listing widgets'" do
1616
get :index
17-
response.body.should =~ /Listing widgets/m
17+
expect(response.body).to match /Listing widgets/m
1818
end
1919
end
2020
end
@@ -34,7 +34,7 @@ Feature: render_views
3434
describe "GET index" do
3535
it "renders the actual template" do
3636
get :index
37-
response.body.should =~ /Listing widgets/m
37+
expect(response.body).to match /Listing widgets/m
3838
end
3939
end
4040
@@ -44,7 +44,7 @@ Feature: render_views
4444
describe "GET index" do
4545
it "renders the RSpec generated template" do
4646
get :index
47-
response.body.should eq("")
47+
expect(response.body).to eq("")
4848
end
4949
end
5050
end
@@ -54,7 +54,7 @@ Feature: render_views
5454
describe "GET index" do
5555
it "renders the RSpec generated template" do
5656
get :index
57-
response.body.should eq("")
57+
expect(response.body).to eq("")
5858
end
5959
end
6060
end
@@ -65,7 +65,7 @@ Feature: render_views
6565
describe "GET index" do
6666
it "renders the actual template" do
6767
get :index
68-
response.body.should =~ /Listing widgets/m
68+
expect(response.body).to match /Listing widgets/m
6969
end
7070
end
7171
end
@@ -104,7 +104,7 @@ Feature: render_views
104104
describe "GET index" do
105105
it "renders the index template" do
106106
get :index
107-
response.body.should =~ /Listing widgets/m
107+
expect(response.body).to match /Listing widgets/m
108108
end
109109
end
110110
end

features/helper_specs/helper_spec.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Feature: helper spec
2121
describe ApplicationHelper do
2222
describe "#page_title" do
2323
it "returns the default title" do
24-
helper.page_title.should eq("RSpec is your friend")
24+
expect(helper.page_title).to eq("RSpec is your friend")
2525
end
2626
end
2727
end
@@ -46,7 +46,7 @@ Feature: helper spec
4646
describe "#page_title" do
4747
it "returns the instance variable" do
4848
assign(:title, "My Title")
49-
helper.page_title.should eql("My Title")
49+
expect(helper.page_title).to eql("My Title")
5050
end
5151
end
5252
end
@@ -71,7 +71,7 @@ Feature: helper spec
7171
describe "#widget_title" do
7272
it "includes the app name" do
7373
assign(:title, "This Widget")
74-
helper.widget_title.should eq("The App: This Widget")
74+
expect(helper.widget_title).to eq("The App: This Widget")
7575
end
7676
end
7777
end

features/mailer_specs/url_helpers.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feature: URL helpers in mailer examples
1111
1212
describe Notifications do
1313
it 'should have access to URL helpers' do
14-
lambda { gadgets_url }.should_not raise_error
14+
expect { gadgets_url }.not_to raise_error
1515
end
1616
end
1717
"""
@@ -29,8 +29,8 @@ Feature: URL helpers in mailer examples
2929
3030
describe Notifications do
3131
it 'should have access to URL helpers' do
32-
lambda { gadgets_url :host => 'example.com' }.should_not raise_error
33-
lambda { gadgets_url }.should raise_error
32+
expect { gadgets_url :host => 'example.com' }.not_to raise_error
33+
expect { gadgets_url }.to raise_error
3434
end
3535
end
3636
"""

features/matchers/new_record_matcher.feature

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@ Feature: be_a_new matcher
1313
1414
describe Widget do
1515
context "when initialized" do
16-
subject { Widget.new }
17-
it { should be_a_new(Widget) }
18-
it { should_not be_a_new(String) }
16+
subject(:widget) { Widget.new }
17+
18+
it "is a new widget" do
19+
expect(widget).to be_a_new(Widget)
20+
end
21+
22+
it "is not a new string" do
23+
expect(widget).not_to be_a_new(String)
24+
end
1925
end
26+
2027
context "when saved" do
21-
subject { Widget.create }
22-
it { should_not be_a_new(Widget) }
23-
it { should_not be_a_new(String) }
28+
subject(:widget) { Widget.create }
29+
30+
it "is not a new widget" do
31+
expect(widget).not_to be_a_new(Widget)
32+
end
33+
34+
it "is not a new string" do
35+
expect(widget).not_to be_a_new(String)
36+
end
2437
end
2538
end
2639
"""

0 commit comments

Comments
 (0)