Class: E2e::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/e2e/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#configure_rubocopObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/e2e/install_generator.rb', line 31

def configure_rubocop
  return unless File.exist?(".rubocop.yml")

  config_content = File.read(".rubocop.yml")

  if config_content.include?("inherit_gem:")
    inject_into_file ".rubocop.yml", after: "inherit_gem:\n" do
      "  e2e: config/rubocop.yml\n"
    end
  else
    prepend_to_file ".rubocop.yml" do
      "inherit_gem:\n  e2e: config/rubocop.yml\n\n"
    end
  end
end

#create_helper_fileObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/e2e/install_generator.rb', line 11

def create_helper_file
  case test_framework
  when :rspec
    create_rspec_helper
  when :minitest
    create_minitest_helper
  else
    say "Could not detect test framework. Please specify --test-framework=rspec or minitest.", :red
  end
end

#display_instructionsObject



22
23
24
25
26
27
28
29
# File 'lib/generators/e2e/install_generator.rb', line 22

def display_instructions
  case test_framework
  when :rspec
    say "E2E gem installed for RSpec! Use `require 'e2e_helper'` in specs.", :green
  when :minitest
    say "E2E gem installed for Minitest! Inherit from `E2E::Minitest::TestCase` in your tests.", :green
  end
end