diff --git a/spec/fixtures/rails b/spec/fixtures/rails new file mode 100755 index 00000000..03b8d5b5 --- /dev/null +++ b/spec/fixtures/rails @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails gems +# installed from the root of your application. + +APP_PATH = File.expand_path('../../../../spec/dummy/config/application', __dir__) + +require 'rails/all' diff --git a/spec/generators/graphql_devise/install_generator_spec.rb b/spec/generators/graphql_devise/install_generator_spec.rb index fcca3bc1..6a6484ca 100644 --- a/spec/generators/graphql_devise/install_generator_spec.rb +++ b/spec/generators/graphql_devise/install_generator_spec.rb @@ -3,17 +3,18 @@ require 'generators/graphql_devise/install_generator' RSpec.describe GraphqlDevise::InstallGenerator, type: :generator do - destination File.expand_path('../../../tmp', __FILE__) + destination File.expand_path('../../../tmp/dummy', __dir__) before do prepare_destination + copy_rails_bin end let(:routes_path) { "#{destination_root}/config/routes.rb" } let(:routes_content) { File.read(routes_path) } let(:dta_route) { "mount_devise_token_auth_for 'User', at: 'auth'" } - xcontext 'when the file exists' do + context 'when the file exists' do before do create_file_with_content( routes_path, @@ -42,11 +43,16 @@ end end - xcontext 'when file does *NOT* exist' do + context 'when file does *NOT* exist' do before { run_generator } it 'does *NOT* create the file and throw no exception' do - expect(File.exist?(routes_path)).to be_falsey + expect(File).not_to exist(routes_path) end end + + def copy_rails_bin + FileUtils.mkdir_p(File.join(destination_root, 'bin')) + FileUtils.copy_file('spec/fixtures/rails', File.join(destination_root, 'bin/rails')) + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6fc99bcb..041c624f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,7 @@ SimpleCov.formatter = Coveralls::SimpleCov::Formatter SimpleCov.start 'rails' do - add_filter ['spec', 'lib/generators'] + add_filter ['spec'] end end