Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update README to use expect syntax #713

Closed
wants to merge 1 commit into from

2 participants

gautamkpai Sam Phippen
gautamkpai

No description provided.

Sam Phippen
Collaborator

I like this. @alindeman @myronmarston do you think we should merge this. (I'd probably merge this as it stands).

alindeman alindeman closed this pull request from a commit
alindeman alindeman Merge branch 'update_readme'
[Closes #713]
55b6d6f
alindeman alindeman closed this in 55b6d6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 15, 2013
  1. gautamkpai
This page is out of date. Refresh to see the latest.
16 features/controller_specs/README.md
View
@@ -12,15 +12,15 @@ specify expected outcomes such as:
* cookies sent back with the response
To specify outcomes, you can use:
-
-* standard rspec matchers (`response.code.should eq(200)`)
+
+* standard rspec matchers (`expect(response.code).to eq(200)`)
* standard test/unit assertions (`assert_equal 200, response.code`)
* rails assertions (`assert_response 200`)
* rails-specific matchers:
- * `response.should render_template (wraps assert_template)`
- * `response.should redirect_to (wraps assert_redirected_to)`
- * `assigns(:widget).should be_a_new(Widget)`
-
+ * `expect(response).to render_template(wraps assert_template)`
+ * `expect(response).to redirect_to(wraps assert_redirected_to)`
+ * `expect(assigns(:widget)).to be_a_new(Widget)`
+
## Examples
describe TeamsController do
@@ -28,12 +28,12 @@ To specify outcomes, you can use:
it "assigns @teams" do
team = Team.create
get :index
- assigns(:teams).should eq([team])
+ expect(assigns(:teams)).to eq([team])
end
it "renders the index template" do
get :index
- response.should render_template("index")
+ expect(response).to render_template("index")
end
end
end
6 features/matchers/README.md
View
@@ -4,15 +4,15 @@ rspec-compatible wrappers for Rails' assertions.
### redirects
# delegates to assert_redirected_to
- response.should redirect_to(path)
+ expect(response).to redirect_to(path)
### templates
# delegates to assert_template
- response.should render_template(template_name)
+ expect(response).to render_template(template_name)
### assigned objects
# passes if assigns(:widget) is an instance of Widget
# and it is not persisted
- assigns(:widget).should be_a_new(Widget)
+ expect(assigns(:widget)).to be_a_new(Widget)
13 features/routing_specs/README.md
View
@@ -5,13 +5,12 @@ Simple apps with nothing but standard RESTful routes won't get much value from
routing specs, but they can provide significant value when used to specify
customized routes, like vanity links, slugs, etc.
- { :get => "/articles/2012/11/when-to-use-routing-specs" }.
- should route_to(
- :controller => "articles",
- :month => "2012-11",
- :slug => "when-to-use-routing-specs"
- )
+ expect(:get => "/articles/2012/11/when-to-use-routing-specs").to route_to(
+ :controller => "articles",
+ :month => "2012-11",
+ :slug => "when-to-use-routing-specs"
+ )
They are also valuable for routes that should not be available:
- { :delete => "/accounts/37" }.should_not be_routable
+ expect (:delete => "/accounts/37").not_to be_routable
Something went wrong with that request. Please try again.