Permalink
Browse files

doc tweaks

  • Loading branch information...
dchelimsky committed Jan 2, 2011
1 parent 5a5e26d commit 3a5cba4ace0bbd04314cfd3ae80593556e2bd332
@@ -5,10 +5,10 @@ A controller spec is an RSpec wrapper for a Rails functional test
(ActionController::TestCase::Behavior). It allows you to simulate a single
http request in each example, and then specify expected outcomes, including:
-* templates that are rendered by the action
-* instance variables that are assigned in the controller to be shared with the
- view
-* cookies that get sent back with the response
+* rendered templates
+* redirects
+* instance variables assigned in the controller to be shared with the view
+* cookies sent back with the response
To specify outcomes, you can use:
@@ -1,7 +1,7 @@
Feature: render_views
- You can tell a controller example group to render views with the render_views
- declaration.
+ You can tell a controller example group to render views with the
+ `render_views` declaration.
Scenario: expect template that exists and is rendered by controller (passes)
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
@@ -1,7 +1,8 @@
Feature: helper spec
- Helper specs live in `spec/helpers`. In order to access the helper methods
- you can call them on the `helper` object.
+ Helper specs live in `spec/helpers`, or any example group with `:type =>
+ :helper`. In order to access the helper methods you can call them on the
+ `helper` object.
Scenario: helper method that returns true
Given a file named "spec/helpers/application_helper_spec.rb" with:
@@ -1,10 +1,10 @@
Feature: be_a_new matcher
- The be_a_new matcher accepts a class and passes if the subject is an instance
- of that class that returns true to new_record?
+ The `be_a_new` matcher accepts a class and passes if the subject is an
+ instance of that class that returns false to persisted?
- You can also call "with" on be_a_new with a hash of attributes to specify the
- subject has equal attributes.
+ You can also chain `with` on `be_a_new` with a hash of attributes to specify
+ the subject has equal attributes.
Scenario: example spec with four be_a_new possibilities
Given a file named "spec/models/widget_spec.rb" with:
@@ -1,9 +1,8 @@
Feature: redirect_to matcher
- The redirect_to matcher is used to specify that the redirect called
- in the latest action ended with the intended behaviour. Essentially,
- it delegates to "assert_redirect". For more info, please check out
- the Rails documentation on this method.
+ The `redirect_to` matcher is used to specify that the redirect called in the
+ latest action ended with the intended behaviour. Essentially, it delegates to
+ [`assert_redirected_to`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to).
It is available in controller specs (spec/controllers) and request
specs (spec/requests).
@@ -38,4 +37,4 @@ Feature: redirect_to matcher
end
"""
When I run "rspec spec/controllers/widgets_controller_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the output should contain "4 examples, 0 failures"
@@ -1,7 +1,9 @@
-Model specs live in spec/models, e.g. spec/models/account_spec.rb. A model spec
-is a thin wrapper for an ActiveSupport::TestCase, and includes all of the
-behavior and assertions that it provides, in addition to RSpec's own behavior
-and expectations.
+Model specs live in `spec/models` or any example group with
+`:type => :model`.
+
+A model spec is a thin wrapper for an ActiveSupport::TestCase, and includes all
+of the behavior and assertions that it provides, in addition to RSpec's own
+behavior and expectations.
## Examples

0 comments on commit 3a5cba4

Please sign in to comment.