File tree Expand file tree Collapse file tree 3 files changed +17
-18
lines changed
Expand file tree Collapse file tree 3 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -12,28 +12,28 @@ specify expected outcomes such as:
1212* cookies sent back with the response
1313
1414To 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
Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff line change @@ -5,13 +5,12 @@ Simple apps with nothing but standard RESTful routes won't get much value from
55routing specs, but they can provide significant value when used to specify
66customized 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
1514They 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
You can’t perform that action at this time.
0 commit comments