Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions spec/fixtures/rails
Original file line number Diff line number Diff line change
@@ -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'
14 changes: 10 additions & 4 deletions spec/generators/graphql_devise/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start 'rails' do
add_filter ['spec', 'lib/generators']
add_filter ['spec']
end
end

Expand Down