Skip to content

Commit 6f7fae2

Browse files
committed
Improve README.
1 parent 3aed96d commit 6f7fae2

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Rails::Controller::Testing
22

3-
TODO
3+
This gem brings back `assigns()` to your controller tests as well as `assert_template`
4+
to both controller and integration tests.
5+
6+
Note: This gem is only useful once `assigns()` and `assert_template` have been
7+
removed from Rails.
48

59
## Installation
610

@@ -18,7 +22,31 @@ Or install it yourself as:
1822

1923
## Usage
2024

21-
TODO
25+
### assigns()
26+
27+
`assigns()` allows you to access the instance variables that have been passed to
28+
your views.
29+
30+
```ruby
31+
class PostsController < ActionController::Base
32+
def index
33+
@posts = Post.all
34+
end
35+
end
36+
37+
class PostControllerTest < ActionController::TestCase
38+
def test_index
39+
get :index
40+
assert_equal Post.all, assigns(:posts)
41+
end
42+
end
43+
```
44+
45+
### assert_template
46+
47+
`assert_template` allows to you assert that certain templates have been rendered.
48+
49+
TODO: Provide examples.
2250

2351
## Contributing
2452

0 commit comments

Comments
 (0)