Class: Suspenders::TestingGenerator

Inherits:
Generators::Base show all
Defined in:
lib/suspenders/generators/testing_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

default_source_root, inherited

Methods included from Actions

#action_mailer_asset_host, #action_mailer_host, #configure_environment, #expand_json, #replace_in_file

Instance Method Details

#add_testing_gemsObject



5
6
7
8
9
10
11
# File 'lib/suspenders/generators/testing_generator.rb', line 5

def add_testing_gems
  gem "spring-commands-rspec", group: :development
  gem "rspec-rails", "~> 3.6", group: %i[development test]
  gem "shoulda-matchers", group: :test

  Bundler.with_unbundled_env { run "bundle install" }
end

#configure_action_mailer_in_specsObject



40
41
42
# File 'lib/suspenders/generators/testing_generator.rb', line 40

def configure_action_mailer_in_specs
  copy_file "action_mailer.rb", "spec/support/action_mailer.rb"
end

#configure_i18n_for_test_environmentObject



36
37
38
# File 'lib/suspenders/generators/testing_generator.rb', line 36

def configure_i18n_for_test_environment
  copy_file "i18n.rb", "spec/support/i18n.rb"
end

#configure_rspecObject



17
18
19
20
21
22
# File 'lib/suspenders/generators/testing_generator.rb', line 17

def configure_rspec
  remove_file "spec/rails_helper.rb"
  remove_file "spec/spec_helper.rb"
  copy_file "rails_helper.rb", "spec/rails_helper.rb"
  copy_file "spec_helper.rb", "spec/spec_helper.rb"
end

#configure_system_testsObject



31
32
33
34
# File 'lib/suspenders/generators/testing_generator.rb', line 31

def configure_system_tests
  empty_directory_with_keep_file "spec/system"
  empty_directory_with_keep_file "spec/support/system"
end

#generate_rspecObject



13
14
15
# File 'lib/suspenders/generators/testing_generator.rb', line 13

def generate_rspec
  generate "rspec:install"
end

#provide_shoulda_matchers_configObject



24
25
26
27
28
29
# File 'lib/suspenders/generators/testing_generator.rb', line 24

def provide_shoulda_matchers_config
  copy_file(
    "shoulda_matchers_config_rspec.rb",
    "spec/support/shoulda_matchers.rb"
  )
end