Class: Trek::Generators::Install::SpecsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/trek/install/specs_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_gemsObject



15
16
17
18
19
20
21
22
23
# File 'lib/generators/trek/install/specs_generator.rb', line 15

def add_gems
  gem "rspec-rails", "~> 8.0", group: [:development, :test] unless in_gemfile?("rspec-rails")
  gem "capybara", "~> 3.38", group: [:test] unless in_gemfile?("capybara")
  gem "rspec_junit_formatter", "~> 0.6.0", group: [:test] unless in_gemfile?("rspec_junit_formatter")
  gem "rspec-html-matchers", "~> 0.10.0", group: [:test] unless in_gemfile?("rspec-html-matchers")
  gem "simplecov", "~> 0.22.0", group: [:test] unless in_gemfile?("simplecov")

  run "bundle install --quiet", abort_on_failure: true
end

#create_rspec_configObject



29
30
31
32
33
34
35
# File 'lib/generators/trek/install/specs_generator.rb', line 29

def create_rspec_config
  create_file ".rspec", <<~TEXT
    --format documentation
    --color
    --require spec_helper
  TEXT
end

#remove_test_directoryObject



37
38
39
40
41
# File 'lib/generators/trek/install/specs_generator.rb', line 37

def remove_test_directory
  return unless File.directory?("test")

  run "rm -rf test" if yes?("Do you want to remove the /test directory?")
end

#run_installObject



25
26
27
# File 'lib/generators/trek/install/specs_generator.rb', line 25

def run_install
  generate "rspec:install"
end