File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,28 @@ Feature: View specs
153
153
When I run `rspec spec/views`
154
154
Then the examples should all pass
155
155
156
+ Scenario : View specs can render a template with locals
157
+ Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
158
+ """ruby
159
+ require "rails_helper"
160
+
161
+ RSpec.describe "widgets/index" do
162
+ it "displays the widget" do
163
+ widget = Widget.create!(:name => "slicer")
164
+
165
+ render :locals => {:widget => widget}
166
+
167
+ expect(rendered).to match /slicer/
168
+ end
169
+ end
170
+ """
171
+ And a file named "app/views/widgets/index.html.erb" with:
172
+ """
173
+ <h3><%= widget.name %></h3>
174
+ """
175
+ When I run `rspec spec/views`
176
+ Then the examples should all pass
177
+
156
178
Scenario : View specs can render locals in a partial
157
179
Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
158
180
"""ruby
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ module ExampleMethods
65
65
# end
66
66
def render ( options = { } , local_assigns = { } , &block )
67
67
options = _default_render_options if Hash === options && options . empty?
68
+ options = options . merge ( _default_render_options ) if Hash === options && options . keys == [ :locals ]
68
69
super ( options , local_assigns , &block )
69
70
end
70
71
You can’t perform that action at this time.
0 commit comments