Class: Rsg::Generators::Testing::RspecGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rsg/generators/testing/rspec_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_rspecObject



6
7
8
# File 'lib/rsg/generators/testing/rspec_generator.rb', line 6

def add_rspec
  append_gem "rspec-rails", within_group: [:development, :test]
end


2
3
4
# File 'lib/rsg/generators/testing/rspec_generator.rb', line 2

def banner
  say "Configuring rspec"
end

#enable_recommendationsObject



18
19
20
# File 'lib/rsg/generators/testing/rspec_generator.rb', line 18

def enable_recommendations
  gsub_file "spec/spec_helper.rb", /^# The settings below[^=]+=begin\n(.+)\n=end/m, '\1'
end

#gitignoreObject



10
11
12
# File 'lib/rsg/generators/testing/rspec_generator.rb', line 10

def gitignore
  append_file ".gitignore", "\n# Ignore rspec state\n/spec/examples.txt\n"
end

#installObject



14
15
16
# File 'lib/rsg/generators/testing/rspec_generator.rb', line 14

def install
  generate("rspec:install")
end

#no_ci_focusObject



22
23
24
25
26
# File 'lib/rsg/generators/testing/rspec_generator.rb', line 22

def no_ci_focus
  gsub_file "spec/spec_helper.rb", /^  config\.filter_run_when_matching :focus$/ do
    "  if ENV.key?(\"CI\")\n    config.filter_run_when_matching :focus\n  end"
  end
end