@@ -2,7 +2,7 @@ Feature: view spec
2
2
3
3
View specs live in spec/views and render view templates in isolation.
4
4
5
- Scenario : passing spec that renders the described view file
5
+ Scenario : View specs render the described view file
6
6
Given a file named "spec/views/widgets/index.html.erb_spec.rb" with:
7
7
"""ruby
8
8
require "rails_helper"
@@ -24,7 +24,7 @@ Feature: view spec
24
24
When I run `rspec spec/views`
25
25
Then the examples should all pass
26
26
27
- Scenario : passing spec with before and nesting
27
+ Scenario : View specs can have before block and nesting
28
28
Given a file named "spec/views/widgets/index.html.erb_spec.rb" with:
29
29
"""ruby
30
30
require "rails_helper"
@@ -51,7 +51,7 @@ Feature: view spec
51
51
When I run `rspec spec/views`
52
52
Then the examples should all pass
53
53
54
- Scenario : passing spec with explicit template rendering
54
+ Scenario : View specs can explicitly render templates
55
55
Given a file named "spec/views/widgets/widget.html.erb_spec.rb" with:
56
56
"""ruby
57
57
require "rails_helper"
@@ -73,7 +73,7 @@ Feature: view spec
73
73
When I run `rspec spec/views`
74
74
Then the examples should all pass
75
75
76
- Scenario : passing spec with a description that includes the format and handler
76
+ Scenario : View specs can have description that includes the format and handler
77
77
Given a file named "spec/views/widgets/widget.xml.erb_spec.rb" with:
78
78
"""ruby
79
79
require "rails_helper"
@@ -105,7 +105,7 @@ Feature: view spec
105
105
When I run `rspec spec/views`
106
106
Then the examples should all pass
107
107
108
- Scenario : passing spec with rendering of locals in a partial
108
+ Scenario : View specs can render locals in a partial
109
109
Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
110
110
"""ruby
111
111
require "rails_helper"
@@ -127,7 +127,7 @@ Feature: view spec
127
127
When I run `rspec spec/views`
128
128
Then the examples should all pass
129
129
130
- Scenario : passing spec with rendering of locals in an implicit partial
130
+ Scenario : View specs can render locals in an implicit partial
131
131
Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
132
132
"""ruby
133
133
require "rails_helper"
@@ -149,7 +149,7 @@ Feature: view spec
149
149
When I run `rspec spec/views`
150
150
Then the examples should all pass
151
151
152
- Scenario : passing spec with rendering of text
152
+ Scenario : View specs can render text
153
153
Given a file named "spec/views/widgets/direct.html.erb_spec.rb" with:
154
154
"""ruby
155
155
require "rails_helper"
@@ -166,7 +166,7 @@ Feature: view spec
166
166
When I run `rspec spec/views`
167
167
Then the examples should all pass
168
168
169
- Scenario : passing view spec that stubs a helper method
169
+ Scenario : View specs can stub a helper method
170
170
Given a file named "app/helpers/application_helper.rb" with:
171
171
"""ruby
172
172
module ApplicationHelper
@@ -199,7 +199,7 @@ Feature: view spec
199
199
When I run `rspec spec/views/secrets`
200
200
Then the examples should all pass
201
201
202
- Scenario : request.path_parameters should match Rails by using symbols for keys
202
+ Scenario : View specs use symbols for keys in ` request.path_parameters` to match Rails style
203
203
Given a file named "spec/views/widgets/index.html.erb_spec.rb" with:
204
204
"""ruby
205
205
require "rails_helper"
@@ -212,3 +212,34 @@ Feature: view spec
212
212
"""
213
213
When I run `rspec spec/views`
214
214
Then the examples should all pass
215
+
216
+ Scenario : View spec actions that do not require extra parameters have `request.fullpath` set
217
+ Given a file named "spec/views/widgets/index.html.erb_spec.rb" with:
218
+ """ruby
219
+ require "rails_helper"
220
+
221
+ RSpec.describe "widgets/index" do
222
+ it "has a request.fullpath that is defined" do
223
+ expect(controller.request.fullpath).to eq widgets_path
224
+ end
225
+ end
226
+ """
227
+ When I run `rspec spec/views`
228
+ Then the examples should all pass
229
+
230
+ Scenario : View spec actions that require extra parameters have `request.fullpath` set when the developer supplies them
231
+ Given a file named "spec/views/widgets/show.html.erb_spec.rb" with:
232
+ """ruby
233
+ require "rails_helper"
234
+
235
+ RSpec.describe "widgets/show" do
236
+ it "displays the widget with id: 1" do
237
+ widget = Widget.create!(:name => "slicer")
238
+ controller.extra_params = { :id => widget.id }
239
+
240
+ expect(controller.request.fullpath).to eq widget_path(widget)
241
+ end
242
+ end
243
+ """
244
+ When I run `rspec spec/views`
245
+ Then the examples should all pass
0 commit comments