Skip to content

Commit 93abddc

Browse files
committed
Enable generator specs, fix for Rails >= 6.0
1 parent 5eee11b commit 93abddc

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

spec/fixtures/rails

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env ruby
2+
# This command will automatically be run when you run "rails" with Rails gems
3+
# installed from the root of your application.
4+
5+
APP_PATH = File.expand_path('../../../../spec/dummy/config/application', __dir__)
6+
7+
require 'rails/all'

spec/generators/graphql_devise/install_generator_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
require 'generators/graphql_devise/install_generator'
44

55
RSpec.describe GraphqlDevise::InstallGenerator, type: :generator do
6-
destination File.expand_path('../../../tmp', __FILE__)
6+
destination File.expand_path('../../../tmp/dummy', __dir__)
77

88
before do
99
prepare_destination
10+
copy_rails_bin
1011
end
1112

1213
let(:routes_path) { "#{destination_root}/config/routes.rb" }
1314
let(:routes_content) { File.read(routes_path) }
1415
let(:dta_route) { "mount_devise_token_auth_for 'User', at: 'auth'" }
1516

16-
xcontext 'when the file exists' do
17+
context 'when the file exists' do
1718
before do
1819
create_file_with_content(
1920
routes_path,
@@ -42,11 +43,16 @@
4243
end
4344
end
4445

45-
xcontext 'when file does *NOT* exist' do
46+
context 'when file does *NOT* exist' do
4647
before { run_generator }
4748

4849
it 'does *NOT* create the file and throw no exception' do
49-
expect(File.exist?(routes_path)).to be_falsey
50+
expect(File).not_to exist(routes_path)
5051
end
5152
end
53+
54+
def copy_rails_bin
55+
FileUtils.mkdir_p(File.join(destination_root, 'bin'))
56+
FileUtils.copy_file('spec/fixtures/rails', File.join(destination_root, 'bin/rails'))
57+
end
5258
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
66
SimpleCov.start 'rails' do
7-
add_filter ['spec', 'lib/generators']
7+
add_filter ['spec']
88
end
99
end
1010

0 commit comments

Comments
 (0)