Class: SeleniumRecord::Generators::InstallGenerator

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

Overview

Generator for installing selenium record in project

Instance Method Summary collapse

Instance Method Details

#add_includes_spec_helperObject



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

def add_includes_spec_helper
  prepend_to_file 'spec/spec_helper.rb' do
    "# SeleniumRecord install configuration\n" \
    "require 'selenium-webdriver'\n" \
    "require 'selenium_record'\n" \
    "require_relative 'support/selenium_objects/base'\n\n"
  end
end

#create_autoloadObject



35
36
37
38
39
40
41
# File 'lib/generators/selenium_record/install_generator.rb', line 35

def create_autoload
  @navigation_components = options[:navigation_components]
  @navigation_folders = @navigation_components.map do |component|
    ActiveSupport::Inflector.pluralize(component)
  end.join(' ')
  template 'autoload.rb.erb', File.join(object_module_path, 'autoload.rb')
end

#create_base_dirObject

def create_initializer_file

template 'selenium_record.rb.erb',
         'config/initializers/selenium_record.rb'

end



23
24
25
# File 'lib/generators/selenium_record/install_generator.rb', line 23

def create_base_dir
  empty_directory object_module_path
end

#create_common_componentsObject



27
28
29
# File 'lib/generators/selenium_record/install_generator.rb', line 27

def create_common_components
  %w(page view).each { |c| create_component(c) }
end

#create_navigation_componentsObject



31
32
33
# File 'lib/generators/selenium_record/install_generator.rb', line 31

def create_navigation_components
  options[:navigation_components].each { |c| create_component(c) }
end