Skip to content

Commit 4feee41

Browse files
gautamkpaialindeman
authored andcommitted
Update README to use expect syntax
1 parent 2418c8e commit 4feee41

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

features/controller_specs/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ specify expected outcomes such as:
1212
* cookies sent back with the response
1313

1414
To specify outcomes, you can use:
15-
16-
* standard rspec matchers (`response.code.should eq(200)`)
15+
16+
* standard rspec matchers (`expect(response.code).to eq(200)`)
1717
* standard test/unit assertions (`assert_equal 200, response.code`)
1818
* rails assertions (`assert_response 200`)
1919
* rails-specific matchers:
20-
* `response.should render_template (wraps assert_template)`
21-
* `response.should redirect_to (wraps assert_redirected_to)`
22-
* `assigns(:widget).should be_a_new(Widget)`
23-
20+
* `expect(response).to render_template(wraps assert_template)`
21+
* `expect(response).to redirect_to(wraps assert_redirected_to)`
22+
* `expect(assigns(:widget)).to be_a_new(Widget)`
23+
2424
## Examples
2525

2626
describe TeamsController do
2727
describe "GET index" do
2828
it "assigns @teams" do
2929
team = Team.create
3030
get :index
31-
assigns(:teams).should eq([team])
31+
expect(assigns(:teams)).to eq([team])
3232
end
3333

3434
it "renders the index template" do
3535
get :index
36-
response.should render_template("index")
36+
expect(response).to render_template("index")
3737
end
3838
end
3939
end

features/matchers/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ rspec-compatible wrappers for Rails' assertions.
44
### redirects
55

66
# delegates to assert_redirected_to
7-
response.should redirect_to(path)
7+
expect(response).to redirect_to(path)
88

99
### templates
1010

1111
# delegates to assert_template
12-
response.should render_template(template_name)
12+
expect(response).to render_template(template_name)
1313

1414
### assigned objects
1515

1616
# passes if assigns(:widget) is an instance of Widget
1717
# and it is not persisted
18-
assigns(:widget).should be_a_new(Widget)
18+
expect(assigns(:widget)).to be_a_new(Widget)

features/routing_specs/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ Simple apps with nothing but standard RESTful routes won't get much value from
55
routing specs, but they can provide significant value when used to specify
66
customized routes, like vanity links, slugs, etc.
77

8-
{ :get => "/articles/2012/11/when-to-use-routing-specs" }.
9-
should route_to(
10-
:controller => "articles",
11-
:month => "2012-11",
12-
:slug => "when-to-use-routing-specs"
13-
)
8+
expect(:get => "/articles/2012/11/when-to-use-routing-specs").to route_to(
9+
:controller => "articles",
10+
:month => "2012-11",
11+
:slug => "when-to-use-routing-specs"
12+
)
1413

1514
They are also valuable for routes that should not be available:
1615

17-
{ :delete => "/accounts/37" }.should_not be_routable
16+
expect(:delete => "/accounts/37").not_to be_routable

0 commit comments

Comments
 (0)