Class: Trek::Generators::Install::SpecsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Trek::Generators::Install::SpecsGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/trek/install/specs_generator.rb
Instance Method Summary collapse
- #add_gems ⇒ Object
- #create_rspec_config ⇒ Object
- #remove_test_directory ⇒ Object
- #run_install ⇒ Object
Instance Method Details
#add_gems ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/trek/install/specs_generator.rb', line 15 def add_gems install_needed = %w[rspec-rails capybara rspec_junit_formatter rspec-html-matchers simplecov].any? { |name| !in_gemfile?(name) } 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") bundle_install if install_needed end |
#create_rspec_config ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/generators/trek/install/specs_generator.rb', line 30 def create_rspec_config create_file ".rspec", <<~TEXT --format documentation --color --require spec_helper TEXT end |
#remove_test_directory ⇒ Object
38 39 40 41 42 |
# File 'lib/generators/trek/install/specs_generator.rb', line 38 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_install ⇒ Object
26 27 28 |
# File 'lib/generators/trek/install/specs_generator.rb', line 26 def run_install generate "rspec:install" end |