Skip to content

Commit de824c2

Browse files
committed
Avoid 'mountable_engine?' stub to leak to next specs in the same file
1 parent fb018f1 commit de824c2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Generators are not automatically loaded by Rails
22
require 'generators/rspec/scaffold/scaffold_generator'
33
require 'support/generators'
4+
require 'rspec/support/spec/in_sub_process'
45

56
RSpec.describe Rspec::Generators::ScaffoldGenerator, type: :generator do
7+
include RSpec::Support::InSubProcess
68
setup_default_destination
79

810
describe 'standard request specs' do
@@ -41,12 +43,13 @@
4143
end
4244

4345
describe 'in an engine' do
44-
before do
45-
allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true)
46-
run_generator %w[posts --request_specs]
46+
it do
47+
in_sub_process do
48+
allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true)
49+
run_generator %w[posts --request_specs]
50+
is_expected.to contain('Engine.routes.url_helpers')
51+
end
4752
end
48-
49-
it { is_expected.to contain('Engine.routes.url_helpers') }
5053
end
5154
end
5255

0 commit comments

Comments
 (0)