Class: AutoMock::Generators::AutoMockGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



11
12
13
# File 'lib/generators/auto_mock/auto_mock_generator.rb', line 11

def self.source_root
  @_auto_mock_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

Instance Method Details

#app_nameObject



26
27
28
# File 'lib/generators/auto_mock/auto_mock_generator.rb', line 26

def app_name
  Rails.application.class.name
end

#insert_includeObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/auto_mock/auto_mock_generator.rb', line 15

def insert_include
  spec_helper = 'spec/spec_helper.rb'
  if File.exists?(spec_helper) && File.readlines(spec_helper).grep(/include AutoMock::AutoMockHelper/).blank?
    File.open(spec_helper, 'a') do |f|
      f.puts 'include AutoMock::AutoMockHelper'
    end
  else
    raise Rails::Generators::Error, "First, you must setup rspec by 'rails generate rspec:install'"
  end
end