Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

doc: note that ActionView::TestCase auto-propagates ivars

- Closes #127.
  • Loading branch information...
commit cbf623a210d893a2d437e421eff6cd17c72179b6 1 parent 213a483
@wincent wincent authored dchelimsky committed
Showing with 14 additions and 2 deletions.
  1. +14 −2 README.markdown
16 README.markdown
@@ -129,17 +129,29 @@ View specs live in spec/views, and mix in ActionView::TestCase::Behavior.
rendered.should contain("Chicago")
## `assign(key, val)`
Use this to assign values to instance variables in the view:
assign(:widget, stub_model(Widget))
The code above assigns `stub_model(Widget)` to the `@widget` variable in the view, and then
renders the view.
+Note that because view specs mix in `ActionView::TestCase` behavior, any
+instance variables you set will be transparently propagated into your views
+(similar to how instance variables you set in controller actions are made
+available in views). For example:
+ @widget = stub_model(Widget)
+ render # @widget is available inside the view
+RSpec doesn't officially support this pattern, which only works as a
+side-effect of the inclusion of `ActionView::TestCase`. Be aware that it may be
+made unavailable in the future.
### * Upgrade note
`assign(key, value)` replaces `assigns[key] = value` from rspec-rails-1.3

0 comments on commit cbf623a

Please sign in to comment.
Something went wrong with that request. Please try again.