walter/test/install_generator_test.rb
2021-10-01 01:24:08 +02:00

50 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
require "rails/generators"
require "generators/walter/install_generator"
class InstallGeneratorTest < Rails::Generators::TestCase
tests Walter::Generators::InstallGenerator
destination File.expand_path("../tmp", __dir__)
setup :prepare_destination
test "should generate a migration" do
begin
run_generator
assert_migration "db/migrate/create_walter_histories"
ensure
FileUtils.rm_rf destination_root
end
end
test "should skip the migration when told to do so" do
begin
run_generator ["--skip-migration"]
assert_no_migration "db/migrate/create_walter_histories"
ensure
FileUtils.rm_rf destination_root
end
end
test "should generate an initializer" do
begin
run_generator
assert_file "config/initializers/walter.rb"
assert_file "config/walter.yml"
ensure
FileUtils.rm_rf destination_root
end
end
test "should skip the initializer when told to do so" do
begin
run_generator ["--skip-initializer"]
assert_no_file "config/initializers/walter.rb"
ensure
FileUtils.rm_rf destination_root
end
end
end