Skip to content

Commit 4b30b23

Browse files
committed
Fix prerender env cleanup scope in render options spec
1 parent cee874d commit 4b30b23

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

react_on_rails/spec/react_on_rails/react_component/render_options_spec.rb

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ def with_prerender_env_override_cleared
3838
def build_render_options_with_clean_prerender_env(option:, attrs:)
3939
if option == :prerender
4040
with_prerender_env_override_cleared do
41-
described_class.new(**attrs)
41+
render_options = described_class.new(**attrs)
42+
return yield(render_options) if block_given?
43+
44+
render_options
4245
end
4346
else
44-
described_class.new(**attrs)
47+
render_options = described_class.new(**attrs)
48+
return yield(render_options) if block_given?
49+
50+
render_options
4551
end
4652
end
4753

@@ -214,19 +220,19 @@ def build_render_options_with_clean_prerender_env(option:, attrs:)
214220
options = {}
215221
options[option] = false
216222
attrs = the_attrs(options: options)
217-
opts = build_render_options_with_clean_prerender_env(option: option, attrs: attrs)
218-
219-
expect(opts.public_send(option)).to be false
223+
build_render_options_with_clean_prerender_env(option: option, attrs: attrs) do |opts|
224+
expect(opts.public_send(option)).to be false
225+
end
220226
end
221227
end
222228

223229
context "without #{option} option" do
224230
it "returns #{option} from config" do
225231
ReactOnRails.configuration.public_send(:"#{option}=", true)
226232
attrs = the_attrs
227-
opts = build_render_options_with_clean_prerender_env(option: option, attrs: attrs)
228-
229-
expect(opts.public_send(option)).to be true
233+
build_render_options_with_clean_prerender_env(option: option, attrs: attrs) do |opts|
234+
expect(opts.public_send(option)).to be true
235+
end
230236
end
231237
end
232238
end

0 commit comments

Comments
 (0)