Sha256: 519474b2dd556b70d4ba0a6538b25cc7252ba90d3e2570400c29a464f32fc7bd

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literals: true

require "generators/jobshop/canary/canary_generator"

module Jobshop
  module CLI
    class Canary < Thor
      desc "reset [options]", "Recreate the app used for running tests"
      long_desc <<~DESC
        All the the normal options to `rails new` are applicable but the
        following options may not be changed:

        --database=postgresql
        --skip-bundle
        --skip-gemfile
        --skip-git
        --skip-listen
        --skip-test
      DESC
      def reset(*args)
        FileUtils.rmtree(File.expand_path("spec/canary"))
        Jobshop::Generators::CanaryGenerator.start(
          args.unshift(File.expand_path("spec/canary")),
          jobshop_options: {
            database: "postgresql",
            skip_bundle: true,
            skip_gemfile: true,
            skip_git: true,
            skip_listen: true,
            skip_test: true
          }
        )
      end

      desc "seed", "Seed the test app"
      def seed
        require_environment!
        Jobshop::Engine.load_seed
      end

      no_commands do
        def require_environment!
          begin
            require File.expand_path("spec/canary/config/environment")
          rescue LoadError
            abort "Canary app does not exist. Run `jobshop reset` to create it."
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.167 lib/jobshop/cli/canary.rb