Module: Onotole::Tests

Included in:
AppBuilder
Defined in:
lib/onotole/tests.rb

Instance Method Summary collapse

Instance Method Details

#configure_capybara_webkitObject



18
19
20
# File 'lib/onotole/tests.rb', line 18

def configure_capybara_webkit
  copy_file 'capybara_webkit.rb', 'spec/support/capybara_webkit.rb'
end

#configure_generatorsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/onotole/tests.rb', line 34

def configure_generators
  config = <<-RUBY

config.generators do |generate|
  generate.helper false
  generate.javascript_engine false
  generate.request_specs false
  generate.routing_specs false
  generate.stylesheets false
  generate.test_framework :rspec
  generate.view_specs false
  generate.fixture_replacement :factory_girl
end

  RUBY

  inject_into_class 'config/application.rb', 'Application', config
end

#configure_i18n_for_test_environmentObject



22
23
24
# File 'lib/onotole/tests.rb', line 22

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

#configure_rspecObject



26
27
28
29
30
31
32
# File 'lib/onotole/tests.rb', line 26

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 'deferred_garbage_collection.rb', 'spec/support/deferred_garbage_collection.rb'
  template 'spec_helper.rb.erb', 'spec/spec_helper.rb'
end

#configure_spec_support_featuresObject



64
65
66
67
# File 'lib/onotole/tests.rb', line 64

def configure_spec_support_features
  empty_directory_with_keep_file 'spec/features'
  empty_directory_with_keep_file 'spec/support/features'
end

#enable_database_cleanerObject



53
54
55
# File 'lib/onotole/tests.rb', line 53

def enable_database_cleaner
  copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
end

#generate_factories_fileObject



73
74
75
# File 'lib/onotole/tests.rb', line 73

def generate_factories_file
  copy_file 'factories.rb', 'spec/factories.rb'
end

#generate_rspecObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/onotole/tests.rb', line 4

def generate_rspec
  ['app/views/pages',
   'spec/lib',
   'spec/controllers',
   'spec/helpers',
   'spec/support/matchers',
   'spec/support/mixins',
   'spec/support/shared_examples'].each do |dir|
    run "mkdir #{dir}"
    run "touch #{dir}/.keep"
  end
  rails_generator 'rspec:install'
end

#provide_shoulda_matchers_configObject



57
58
59
60
61
62
# File 'lib/onotole/tests.rb', line 57

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

#raise_on_missing_assets_in_testObject



77
78
79
80
81
82
83
# File 'lib/onotole/tests.rb', line 77

def raise_on_missing_assets_in_test
  inject_into_file(
    'config/environments/test.rb',
    "\n  config.assets.raise_runtime_errors = true",
    after: 'Rails.application.configure do'
  )
end

#set_up_factory_girl_for_rspecObject



69
70
71
# File 'lib/onotole/tests.rb', line 69

def set_up_factory_girl_for_rspec
  copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
end