rspec-rails 3.0.0.beta2 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -1
  4. data/Capybara.md +1 -3
  5. data/Changelog.md +126 -58
  6. data/README.md +31 -4
  7. data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
  8. data/lib/generators/rspec/controller/templates/view_spec.rb +1 -1
  9. data/lib/generators/rspec/feature/templates/feature_spec.rb +1 -1
  10. data/lib/generators/rspec/helper/templates/helper_spec.rb +1 -1
  11. data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +21 -1
  12. data/lib/generators/rspec/integration/templates/request_spec.rb +1 -1
  13. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +1 -1
  14. data/lib/generators/rspec/model/templates/model_spec.rb +1 -1
  15. data/lib/generators/rspec/observer/templates/observer_spec.rb +1 -1
  16. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +11 -3
  17. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +4 -3
  18. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  19. data/lib/generators/rspec/scaffold/templates/new_spec.rb +5 -4
  20. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +1 -1
  21. data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
  22. data/lib/generators/rspec/view/templates/view_spec.rb +1 -1
  23. data/lib/rspec/rails.rb +1 -8
  24. data/lib/rspec/rails/configuration.rb +72 -0
  25. data/lib/rspec/rails/example.rb +0 -64
  26. data/lib/rspec/rails/example/controller_example_group.rb +16 -12
  27. data/lib/rspec/rails/example/feature_example_group.rb +0 -2
  28. data/lib/rspec/rails/example/helper_example_group.rb +0 -2
  29. data/lib/rspec/rails/example/mailer_example_group.rb +0 -1
  30. data/lib/rspec/rails/example/model_example_group.rb +0 -4
  31. data/lib/rspec/rails/example/request_example_group.rb +0 -2
  32. data/lib/rspec/rails/example/routing_example_group.rb +0 -2
  33. data/lib/rspec/rails/example/view_example_group.rb +1 -2
  34. data/lib/rspec/rails/extensions.rb +0 -1
  35. data/lib/rspec/rails/fixture_support.rb +0 -8
  36. data/lib/rspec/rails/matchers.rb +1 -0
  37. data/lib/rspec/rails/matchers/have_http_status.rb +355 -0
  38. data/lib/rspec/rails/matchers/routing_matchers.rb +1 -1
  39. data/lib/rspec/rails/tasks/rspec.rake +12 -5
  40. data/lib/rspec/rails/version.rb +1 -1
  41. data/lib/rspec/rails/view_rendering.rb +6 -34
  42. metadata +42 -316
  43. metadata.gz.sig +0 -0
  44. data/features/Generators.md +0 -25
  45. data/features/GettingStarted.md +0 -84
  46. data/features/README.md +0 -48
  47. data/features/RailsVersions.md +0 -4
  48. data/features/Transactions.md +0 -84
  49. data/features/Upgrade.md +0 -121
  50. data/features/controller_specs/Cookies.md +0 -57
  51. data/features/controller_specs/README.md +0 -45
  52. data/features/controller_specs/anonymous_controller.feature +0 -436
  53. data/features/controller_specs/bypass_rescue.feature +0 -75
  54. data/features/controller_specs/controller_spec.feature +0 -58
  55. data/features/controller_specs/engine_routes.feature +0 -51
  56. data/features/controller_specs/isolation_from_views.feature +0 -87
  57. data/features/controller_specs/render_views.feature +0 -114
  58. data/features/directory_structure.feature +0 -71
  59. data/features/feature_specs/feature_spec.feature +0 -35
  60. data/features/helper_specs/helper_spec.feature +0 -122
  61. data/features/mailer_specs/url_helpers.feature +0 -38
  62. data/features/matchers/README.md +0 -18
  63. data/features/matchers/new_record_matcher.feature +0 -41
  64. data/features/matchers/redirect_to_matcher.feature +0 -40
  65. data/features/matchers/relation_match_array.feature +0 -27
  66. data/features/matchers/render_template_matcher.feature +0 -49
  67. data/features/mocks/mock_model.feature +0 -147
  68. data/features/mocks/stub_model.feature +0 -58
  69. data/features/model_specs/README.md +0 -21
  70. data/features/model_specs/errors_on.feature +0 -51
  71. data/features/model_specs/records.feature +0 -27
  72. data/features/model_specs/transactional_examples.feature +0 -109
  73. data/features/request_specs/request_spec.feature +0 -49
  74. data/features/routing_specs/README.md +0 -16
  75. data/features/routing_specs/be_routable_matcher.feature +0 -80
  76. data/features/routing_specs/engine_routes.feature +0 -38
  77. data/features/routing_specs/named_routes.feature +0 -18
  78. data/features/routing_specs/route_to_matcher.feature +0 -90
  79. data/features/step_definitions/additional_cli_steps.rb +0 -4
  80. data/features/step_definitions/model_steps.rb +0 -3
  81. data/features/support/capybara.rb +0 -7
  82. data/features/support/env.rb +0 -53
  83. data/features/support/rails_versions.rb +0 -4
  84. data/features/support/rubinius.rb +0 -6
  85. data/features/view_specs/inferred_controller_path.feature +0 -45
  86. data/features/view_specs/stub_template.feature +0 -51
  87. data/features/view_specs/view_spec.feature +0 -206
  88. data/lib/rspec/rails/extensions/active_record/base.rb +0 -58
  89. data/lib/rspec/rails/mocks.rb +0 -272
  90. data/lib/rspec/rails/vendor/webrat.rb +0 -33
  91. data/spec/generators/rspec/controller/controller_generator_spec.rb +0 -97
  92. data/spec/generators/rspec/feature/feature_generator_spec.rb +0 -43
  93. data/spec/generators/rspec/helper/helper_generator_spec.rb +0 -30
  94. data/spec/generators/rspec/install/install_generator_spec.rb +0 -30
  95. data/spec/generators/rspec/integration/integration_generator_spec.rb +0 -32
  96. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +0 -48
  97. data/spec/generators/rspec/model/model_generator_spec.rb +0 -52
  98. data/spec/generators/rspec/observer/observer_generator_spec.rb +0 -21
  99. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +0 -138
  100. data/spec/generators/rspec/view/view_generator_spec.rb +0 -41
  101. data/spec/rspec/rails/assertion_adapter_spec.rb +0 -28
  102. data/spec/rspec/rails/assertion_delegator_spec.rb +0 -43
  103. data/spec/rspec/rails/configuration_spec.rb +0 -26
  104. data/spec/rspec/rails/deprecations_spec.rb +0 -18
  105. data/spec/rspec/rails/example/controller_example_group_spec.rb +0 -159
  106. data/spec/rspec/rails/example/feature_example_group_spec.rb +0 -56
  107. data/spec/rspec/rails/example/helper_example_group_spec.rb +0 -66
  108. data/spec/rspec/rails/example/mailer_example_group_spec.rb +0 -21
  109. data/spec/rspec/rails/example/model_example_group_spec.rb +0 -15
  110. data/spec/rspec/rails/example/request_example_group_spec.rb +0 -17
  111. data/spec/rspec/rails/example/routing_example_group_spec.rb +0 -32
  112. data/spec/rspec/rails/example/view_example_group_spec.rb +0 -235
  113. data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +0 -23
  114. data/spec/rspec/rails/extensions/active_record/base_spec.rb +0 -42
  115. data/spec/rspec/rails/fixture_support_spec.rb +0 -17
  116. data/spec/rspec/rails/matchers/be_a_new_spec.rb +0 -142
  117. data/spec/rspec/rails/matchers/be_new_record_spec.rb +0 -33
  118. data/spec/rspec/rails/matchers/be_routable_spec.rb +0 -41
  119. data/spec/rspec/rails/matchers/be_valid_spec.rb +0 -73
  120. data/spec/rspec/rails/matchers/has_spec.rb +0 -29
  121. data/spec/rspec/rails/matchers/have_rendered_spec.rb +0 -93
  122. data/spec/rspec/rails/matchers/redirect_to_spec.rb +0 -81
  123. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +0 -31
  124. data/spec/rspec/rails/matchers/route_to_spec.rb +0 -151
  125. data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +0 -31
  126. data/spec/rspec/rails/mocks/mock_model_spec.rb +0 -400
  127. data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -154
  128. data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +0 -32
  129. data/spec/rspec/rails/view_rendering_spec.rb +0 -111
  130. data/spec/spec_helper.rb +0 -33
  131. data/spec/support/ar_classes.rb +0 -42
  132. data/spec/support/helpers.rb +0 -34
  133. data/spec/support/matchers.rb +0 -9
  134. data/spec/support/null_object.rb +0 -6
metadata.gz.sig CHANGED
Binary file
@@ -1,25 +0,0 @@
1
- RSpec spec are normally generated alongside other application components.
2
- For instance, `rails generate model` will also generate an RSpec spec file
3
- for the model.
4
-
5
- Note that the generators are there to help you get started, but they are no
6
- substitute for writing your own examples, and they are only guaranteed to work
7
- out of the box for with Rails' defaults.
8
-
9
- RSpec generators can also be run independently. For instance,
10
-
11
- rails generate rspec:model widget
12
-
13
- will create a new spec file in `spec/models/widget_spec.rb`.
14
-
15
- The same generator pattern is available for all specs:
16
-
17
- * scaffold
18
- * model
19
- * controller
20
- * helper
21
- * view
22
- * mailer
23
- * observer
24
- * integration
25
- * feature
@@ -1,84 +0,0 @@
1
- Install Rails-3
2
-
3
- $ gem install rails -v "~> 3.0.0"
4
-
5
- ### Generate an app
6
-
7
- $ rails new example
8
- $ cd example
9
-
10
- ### Add rspec-rails to the Gemfile
11
-
12
- $ echo 'gem "rspec-rails", :group => [:development, :test]' >> Gemfile
13
-
14
- ### Install the bundle
15
-
16
- $ bundle install
17
-
18
- ### Bootstrap RSpec
19
-
20
- $ rails generate rspec:install
21
-
22
- ### Generate a scaffold
23
-
24
- $ rails generate scaffold Widgets name:string
25
-
26
- This generates files in the `app` and `spec` directories. The files in the
27
- `app` directory are generated by Rails, and Rails delegates the generation of
28
- the files in the `spec` directory to RSpec.
29
-
30
- ### Run migrations
31
-
32
- $ rake db:migrate && rake db:test:prepare
33
-
34
- ### Run RSpec
35
-
36
- $ rake spec
37
-
38
- or
39
-
40
- $ rspec spec --format documentation
41
-
42
- If all went well, you should see output ending with:
43
-
44
- 29 examples, 0 failures, 2 pending
45
-
46
- This output also includes the following controller spec:
47
-
48
- WidgetsController
49
- GET index
50
- assigns all widgets as @widgets
51
- GET show
52
- assigns the requested widget as @widget
53
- GET new
54
- assigns a new widget as @widget
55
- GET edit
56
- assigns the requested widget as @widget
57
- POST create
58
- with valid params
59
- creates a new Widget
60
- assigns a newly created widget as @widget
61
- redirects to the created widget
62
- with invalid params
63
- assigns a newly created but unsaved widget as @widget
64
- re-renders the 'new' template
65
- PUT update
66
- with valid params
67
- updates the requested widget
68
- assigns the requested widget as @widget
69
- redirects to the widget
70
- with invalid params
71
- assigns the widget as @widget
72
- re-renders the 'edit' template
73
- DELETE destroy
74
- destroys the requested widget
75
- redirects to the widgets list
76
-
77
- Output like this can help to quickly gain a high level understanding of how an
78
- object behaves. It also exposes which cases have been specified and which have
79
- not. Note the balance between the examples for the `create` and `update`
80
- actions. If the `redirects to the widget` example was missing from one or the
81
- other, it would be easy to spot.
82
-
83
- Take a look at the generated `spec/controllers/widgets_controller_spec.rb` to
84
- get a sense of how to organize your specs to generate output like this.
data/features/README.md DELETED
@@ -1,48 +0,0 @@
1
- rspec-rails extends Rails' built-in testing framework to support rspec
2
- examples for requests, controllers, models, views, helpers, mailers and
3
- routing.
4
-
5
- ## Rails
6
-
7
- rspec-rails 3 supports Rails 3.x and 4.x. For earlier versions of Rails, you
8
- need [rspec-rails 1](https://github.com/dchelimsky/rspec-rails).
9
-
10
- ## Install
11
-
12
- gem install rspec-rails
13
-
14
- This installs the following gems:
15
-
16
- rspec
17
- rspec-core
18
- rspec-expectations
19
- rspec-mocks
20
- rspec-rails
21
-
22
- ## Configure
23
-
24
- Add rspec-rails to the :test and :development groups in the Gemfile:
25
-
26
- group :test, :development do
27
- gem 'rspec-rails', '~> 3.0.0.beta'
28
- end
29
-
30
- It needs to be in the :development group to expose generators and rake tasks
31
- without having to type RAILS_ENV=test.
32
-
33
- Now you can run:
34
-
35
- script/rails generate rspec:install
36
-
37
- This adds the spec directory and some skeleton files, including a .rspec
38
- file.
39
-
40
- ## Issues
41
-
42
- The documentation for rspec-rails is a work in progress. We'll be adding
43
- Cucumber features over time, and clarifying existing ones. If you have
44
- specific features you'd like to see added, find the existing documentation
45
- incomplete or confusing, or, better yet, wish to write a missing Cucumber
46
- feature yourself, please [submit an
47
- issue](http://github.com/rspec/rspec-rails/issues) or a [pull
48
- request](http://github.com/rspec/rspec-rails).
@@ -1,4 +0,0 @@
1
- rails version | rspec-rails version
2
- 2.3 | 1.3.4
3
- 3.0 | >= 2.0
4
- 3.1 | >= 2.6
@@ -1,84 +0,0 @@
1
- When you run `rails generate rspec:install`, the `spec/spec_helper.rb` file
2
- includes the following configuration:
3
-
4
- RSpec.configure do |config|
5
- config.use_transactional_fixtures = true
6
- end
7
-
8
- The name of this setting is a bit misleading. What it really means in Rails
9
- is "run every test method within a transaction." In the context of rspec-rails,
10
- it means "run every example within a transaction."
11
-
12
- The idea is to start each example with a clean database, create whatever data
13
- is necessary for that example, and then remove that data by simply rolling back
14
- the transaction at the end of the example.
15
-
16
- ### Disabling transactions
17
-
18
- If you prefer to manage the data yourself, or using another tool like
19
- [database_cleaner](https://github.com/bmabey/database_cleaner) to do it for you,
20
- simply tell RSpec to tell Rails not to manage transactions:
21
-
22
- RSpec.configure do |config|
23
- config.use_transactional_fixtures = false
24
- end
25
-
26
- ### Data created in `before(:each)` are rolled back
27
-
28
- Any data you create in a `before(:each)` hook will be rolled back at the end of
29
- the example. This is a good thing because it means that each example is
30
- isolated from state that would otherwise be left around by the examples that
31
- already ran. For example:
32
-
33
- describe Widget do
34
- before(:each) do
35
- @widget = Widget.create
36
- end
37
-
38
- it "does something" do
39
- expect(@widget).to do_something
40
- end
41
-
42
- it "does something else" do
43
- expect(@widget).to do_something_else
44
- end
45
- end
46
-
47
- The `@widget` is recreated in each of the two examples above, so each example
48
- has a different object, _and_ the underlying data is rolled back so the data
49
- backing the `@widget` in each example is new.
50
-
51
- ### Data created in `before(:all)` are _not_ rolled back
52
-
53
- `before(:all)` hooks are invoked before the transaction is opened. You can use
54
- this to speed things up by creating data once before any example in a group is
55
- run, however, this introduces a number of complications and you should only do
56
- this if you have a firm grasp of the implications. Here are a couple of
57
- guidelines:
58
-
59
- 1. Be sure to clean up any data in an `after(:all)` hook:
60
-
61
- before(:all) do
62
- @widget = Widget.create!
63
- end
64
-
65
- after(:all) do
66
- @widget.destroy
67
- end
68
-
69
- If you don't do that, you'll leave data lying around that will eventually
70
- interfere with other examples.
71
-
72
- 2. Reload the object in a `before(:each)` hook.
73
-
74
- before(:all) do
75
- @widget = Widget.create!
76
- end
77
-
78
- before(:each) do
79
- @widget.reload
80
- end
81
-
82
- Even though database updates in each example will be rolled back, the
83
- object won't _know_ about those rollbacks so the object and its backing
84
- data can easily get out of sync.
data/features/Upgrade.md DELETED
@@ -1,121 +0,0 @@
1
- # Upgrading from rspec-rails-1.x to rspec-rails-2.
2
-
3
- This is a work in progress. Please submit errata, missing steps, or patches to
4
- the [rspec-rails issue tracker](https://github.com/rspec/rspec-rails/issues).
5
-
6
- ## Rake tasks
7
-
8
- Delete lib/tasks/rspec.rake, if present. Rake tasks now live in the rspec-rails
9
- gem.
10
-
11
- ## `spec_helper.rb`
12
-
13
- There were a few changes to the generated `spec/spec_helper.rb` file. We
14
- recommend the following:
15
-
16
- 1. set aside a copy of your existing `spec/spec_helper.rb` file.
17
- 2. run `rails generate rspec:install`
18
- 3. copy any customizations from your old spec_helper to the new one
19
-
20
- If you prefer to make the changes manually in the existing spec_helper, here
21
- is what you need to change:
22
-
23
- # rspec-1
24
- require 'spec/autorun'
25
-
26
- Spec::Runner.configure do |config|
27
- ...
28
- end
29
-
30
- # rspec-2
31
- require 'rspec/rails'
32
-
33
- RSpec.configure do |config|
34
- ...
35
- end
36
-
37
- ## Controller specs
38
-
39
- ### isolation from view templates
40
-
41
- By default, controller specs do _not_ render view templates. This keeps
42
- controller specs isolated from the content of views and their requirements.
43
-
44
- NOTE that the template must exist, but it will not be rendered. This is
45
- different from rspec-rails-1.x, in which the template didn't need to exist, but
46
- ActionController makes a number of new decisions in Rails 3 based on the
47
- existence of the template. To keep the RSpec code free of monkey patches, and
48
- to keep the rspec user experience simpler, we decided that this would be a fair
49
- trade-off.
50
-
51
- ### `response.should render_template`
52
-
53
- This needs to move from before the action to after. For example:
54
-
55
- # rspec-rails-1
56
- controller.should render_template("edit")
57
- get :edit, :id => "37"
58
-
59
- # rspec-rails-2
60
- get :edit, :id => "37"
61
- response.should render_template("edit")
62
-
63
- # rspec-rails-2 with expect syntax
64
- get :edit, :id => "37"
65
- expect(response).to render_template("edit")
66
-
67
- rspec-1 had to monkey patch Rails to get render_template to work before the
68
- action, and this broke a couple of times with Rails releases (requiring urgent
69
- fix releases in RSpec). Part of the philosophy of rspec-rails-2 is to rely on
70
- public APIs in Rails as much as possible. In this case, `render_template`
71
- delegates directly to Rails' `assert_template`, which only works after the
72
- action.
73
-
74
- ## View specs
75
-
76
- ### `view.should render_template`
77
-
78
- Rails changed the way it renders partials, so to set an expectation that a
79
- partial gets rendered, you need
80
-
81
- render
82
- view.should render_template(:partial => "widget/_row")
83
-
84
- ### stub_template
85
-
86
- Introduced in rspec-rails-2.2, simulates the presence of view templates on the
87
- file system. This supports isolation from partials rendered by the vew template
88
- that is the subject of a view example:
89
-
90
- stub_template "widgets/_widget.html.erb" => "This Content"
91
-
92
- ### No more `have_tag` or `have_text`
93
-
94
- Before Webrat came along, rspec-rails had its own `have_tag` and `have_text`
95
- matchers that wrapped Rails' `assert_select`. Webrat included replacements for
96
- these methods, as well as new matchers (`have_selector` and `have_xpath`), all
97
- of which rely on Nokogiri to do its work, and are far less brittle than RSpec's
98
- `have_tag`.
99
-
100
- Capybara has similar matchers, which will soon be available view specs (they
101
- are already available in controller specs with `render_views`).
102
-
103
- Given the brittleness of RSpec's `have_tag` and `have_text` matchers and the
104
- presence of new Webrat and Capybara matchers that do a better job, `have_tag`
105
- and `have_text` were not included in rspec-rails-2.
106
-
107
- ## Mocks, stubs, doubles
108
-
109
- ### as_new_record
110
-
111
- Earlier versions of the view generators generated stub_model with `:new_record?
112
- => true`. That is no longer recognized in rspec-rails-2, so you need to change
113
- this:
114
-
115
- stub_model(Widget, :new_record? => true)
116
-
117
- to this:
118
-
119
- stub_model(Widget).as_new_record
120
-
121
- Generators in 2.0.0 final release will do the latter.
@@ -1,57 +0,0 @@
1
- Controller specs wrap Rails controller tests, which expose a few different ways
2
- to access cookies:
3
-
4
- @request.cookies['key']
5
- @response.cookies['key']
6
- cookies['key']
7
-
8
- rails-3.0.x and 3.1 handle these slightly differently, so to avoid confusion, we recommend
9
- the following guidelines:
10
-
11
- ### Recommended guidelines for rails-3.0.0 to 3.1.0
12
-
13
- * Access cookies through the `request` and `response` objects in the spec.
14
- * Use `request.cookies` before the action to set up state.
15
- * Use `response.cookies` after the action to specify outcomes.
16
- * Use the `cookies` object in the controller action.
17
- * Use String keys.
18
-
19
- <pre>
20
- # spec
21
- request.cookies['foo'] = 'bar'
22
- get :some_action
23
- expect(response.cookies['foo']).to eq('modified bar')
24
-
25
- # controller
26
- def some_action
27
- cookies['foo'] = "modified #{cookies['foo']}"
28
- end
29
- </pre>
30
-
31
- #### Why use Strings instead of Symbols?
32
-
33
- The `cookies` objects in the spec come from Rack, and do not support
34
- indifferent access (i.e. `:foo` and `"foo"` are different keys). The `cookies`
35
- object in the controller _does_ support indifferent access, which is a bit
36
- confusing.
37
-
38
- This changed in rails-3.1, so you _can_ use symbol keys, but we recommend
39
- sticking with string keys for consistency.
40
-
41
- #### Why not use the `cookies` method?
42
-
43
- The `cookies` method combines the `request` and `response` cookies. This can
44
- lead to confusion when setting cookies in the example in order to set up state
45
- for the controller action.
46
-
47
- # does not work in rails 3.0.0 > 3.1.0
48
- cookies['foo'] = 'bar' # this is not visible in the controller
49
- get :some_action
50
-
51
- ### Future versions of Rails
52
-
53
- There is code in the master branch in rails that makes cookie access more
54
- consistent so you can use the same `cookies` object before and after the action,
55
- and you can use String or Symbol keys. We'll update these docs accordingly when
56
- that is released.
57
-
@@ -1,45 +0,0 @@
1
- Controller specs live in `spec/controllers` or any example group with
2
- `:type => :controller`.
3
-
4
- A controller spec is an RSpec wrapper for a Rails functional test
5
- ([ActionController::TestCase::Behavior](https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb)).
6
- It allows you to simulate a single http request in each example, and then
7
- specify expected outcomes such as:
8
-
9
- * rendered templates
10
- * redirects
11
- * instance variables assigned in the controller to be shared with the view
12
- * cookies sent back with the response
13
-
14
- To specify outcomes, you can use:
15
-
16
- * standard rspec matchers (`expect(response.status).to eq(200)`)
17
- * standard test/unit assertions (`assert_equal 200, response.status`)
18
- * rails assertions (`assert_response 200`)
19
- * rails-specific matchers:
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
-
24
- ## Examples
25
-
26
- describe TeamsController do
27
- describe "GET index" do
28
- it "assigns @teams" do
29
- team = Team.create
30
- get :index
31
- expect(assigns(:teams)).to eq([team])
32
- end
33
-
34
- it "renders the index template" do
35
- get :index
36
- expect(response).to render_template("index")
37
- end
38
- end
39
- end
40
-
41
- ## Views
42
-
43
- * by default, views are not rendered. See
44
- [views are stubbed by default](controller-specs/views-are-stubbed-by-default) and
45
- [render_views](controller-specs/render-views) for details.