-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for
rails g good_job:install
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'rails_helper' | ||
require 'generators/good_job/install_generator' | ||
|
||
describe GoodJob::InstallGenerator, type: :generator do | ||
it 'creates a migration for good_jobs table' do | ||
create_dummy_app | ||
|
||
install_good_job | ||
|
||
expect(Dir.glob("#{dummy_app_path}/db/migrate/[0-9]*_create_good_jobs.rb")).not_to be_empty | ||
|
||
remove_dummy_app | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'fileutils' | ||
|
||
module GoodJobTestHelper | ||
def create_dummy_app | ||
FileUtils.cd(tmp_path) do | ||
`rails new dummy --skip-action-mailer --skip-action-mailbox --skip-action-cable --skip-sprockets --skip-listen --skip-javascript --skip-turbolinks --skip-system-test --skip-test-unit --skip-bootsnap --skip-spring` | ||
end | ||
end | ||
|
||
def remove_dummy_app | ||
FileUtils.rm_rf(dummy_app_path) | ||
end | ||
|
||
def install_good_job | ||
File.open("#{dummy_app_path}/Gemfile", 'a') do |f| | ||
f.puts "gem 'good_job'" | ||
end | ||
|
||
FileUtils.cd(dummy_app_path) do | ||
`rails g good_job:install` | ||
end | ||
end | ||
|
||
def dummy_app_path | ||
File.join(tmp_path, 'dummy') | ||
end | ||
|
||
def tmp_path | ||
@_tmp_path ||= File.join(File.dirname(__FILE__), '..') | ||
end | ||
end | ||
|
||
RSpec.configure { |c| c.include GoodJobTestHelper, type: :generator } |