Class: Tuberack::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#capybara_test_helpObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/generators/tuberack/install_generator.rb', line 58

def capybara_test_help
  append_file 'test/test_helper.rb' do
    <<-EOH
# Capybara must be required directly 
if TUBERACK.include?(:capybara)
  begin
    require 'capybara/rails'
  rescue LoadError
    puts "You must put `gem 'capybara'` into your Gemfile and `bundle install` to use Capybara"
  end

  class ActionDispatch::IntegrationTest
    include Capybara::DSL
  end
end
    EOH
  end
end

#codeclimate_test_helpObject



19
20
21
22
23
24
25
26
27
# File 'lib/generators/tuberack/install_generator.rb', line 19

def codeclimate_test_help
  prepend_file 'test/test_helper.rb' do
    <<-EOH

# Don't forget set token
CodeClimate::TestReporter.start if TUBERACK.include?(:codeclimate)
    EOH
  end
end

#copy_simplecovObject



52
53
54
# File 'lib/generators/tuberack/install_generator.rb', line 52

def copy_simplecov
  template ".simplecov", ".simplecov"
end

#coverage_requirementsObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/tuberack/install_generator.rb', line 30

def coverage_requirements
  prepend_file 'test/test_helper.rb' do
    <<-EOH
# Keep it on top, don't change positions
require 'tuberack/codeclimate'
require 'tuberack/simplecov'
require 'tuberack/coveralls'
    EOH
  end
end

#coveralls_test_helpObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/tuberack/install_generator.rb', line 7

def coveralls_test_help
  prepend_file 'test/test_helper.rb' do
    <<-EOH

Coveralls.wear! if Coveralls.should_run? if TUBERACK.include?(:coveralls)
# Coveralls.wear!('rails') # For RailsApp

    EOH
  end
end

#enabled_servicesObject



42
43
44
45
46
47
48
49
# File 'lib/generators/tuberack/install_generator.rb', line 42

def enabled_services
  prepend_file 'test/test_helper.rb' do
    <<-EOH
TUBERACK = [ :minitest, :shoulda, :mocha, :cell, :factory_girl, :webmock, :capybara, :simplecov, :codeclimate, :coveralls ]

    EOH
  end
end

#tuberack_test_helpObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/generators/tuberack/install_generator.rb', line 78

def tuberack_test_help
  file = File.read('test/test_helper.rb').sub(/require ("|')rails\/test_help("|')\n/, "require 'rails\/test_help'\nrequire 'tuberack/test_help'\n")
  File.write('test/test_helper.rb', file)

  append_file 'test/test_helper.rb' do
    <<-EOH
include Tuberack::Helpers
    EOH
  end
  
  append_file 'test/test_helper.rb' do
    <<-EOH

class ActiveSupport::TestCase
  # Uncomment if are you using Rails engine
  # include MyEngine::Engine.routes.url_helpers
end
    EOH
  end
end

#webmock_test_helpObject



100
101
102
103
104
105
106
# File 'lib/generators/tuberack/install_generator.rb', line 100

def webmock_test_help        
  append_file 'test/test_helper.rb' do
    <<-EOH
WebMock.disable_net_connect! allow: %w(coveralls.io) if TUBERACK.include?(:webmock)
    EOH
  end
end