Skip to content

Commit

Permalink
Avoid 'mountable_engine?' stub to leak to next specs in the same file
Browse files Browse the repository at this point in the history
  • Loading branch information
benoittgt committed Nov 21, 2020
1 parent fb018f1 commit de824c2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions spec/generators/rspec/scaffold/scaffold_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Generators are not automatically loaded by Rails
require 'generators/rspec/scaffold/scaffold_generator'
require 'support/generators'
require 'rspec/support/spec/in_sub_process'

RSpec.describe Rspec::Generators::ScaffoldGenerator, type: :generator do
include RSpec::Support::InSubProcess
setup_default_destination

describe 'standard request specs' do
Expand Down Expand Up @@ -41,12 +43,13 @@
end

describe 'in an engine' do
before do
allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true)
run_generator %w[posts --request_specs]
it do
in_sub_process do
allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true)
run_generator %w[posts --request_specs]
is_expected.to contain('Engine.routes.url_helpers')
end
end

it { is_expected.to contain('Engine.routes.url_helpers') }
end
end

Expand Down

0 comments on commit de824c2

Please # to comment.