class RSpecKickstarter::ERBFactory
Public Class Methods
new(custom_template)
click to toggle source
# File lib/rspec_kickstarter/erb_factory.rb, line 12 def initialize(custom_template) @custom_template = custom_template end
Public Instance Methods
get_instance_for_appending(rails_mode, target_path)
click to toggle source
Returns ERB instance for appeding lacking tests
# File lib/rspec_kickstarter/erb_factory.rb, line 27 def get_instance_for_appending(rails_mode, target_path) template = get_erb_template(@custom_template, false, rails_mode, target_path) ERB.new(template, nil, '-', '_additional_spec_code') end
get_instance_for_new_spec(rails_mode, target_path)
click to toggle source
Returns ERB instance for creating new spec
# File lib/rspec_kickstarter/erb_factory.rb, line 19 def get_instance_for_new_spec(rails_mode, target_path) template = get_erb_template(@custom_template, true, rails_mode, target_path) ERB.new(template, nil, '-', '_new_spec_code') end
Private Instance Methods
get_basic_template(is_full)
click to toggle source
# File lib/rspec_kickstarter/erb_factory.rb, line 65 def get_basic_template(is_full) if is_full RSpecKickstarter::ERBTemplates::BASIC_NEW_SPEC_TEMPLATE else RSpecKickstarter::ERBTemplates::BASIC_METHODS_PART_TEMPLATE end end
get_erb_template(custom_template, is_full, rails_mode, target_path)
click to toggle source
Returns ERB template
# File lib/rspec_kickstarter/erb_factory.rb, line 37 def get_erb_template(custom_template, is_full, rails_mode, target_path) if custom_template custom_template elsif rails_mode && target_path.match(/controllers/) get_rails_controller_template(is_full) elsif rails_mode && target_path.match(/helpers/) get_rails_helper_template(is_full) else get_basic_template(is_full) end end
get_rails_controller_template(is_full)
click to toggle source
# File lib/rspec_kickstarter/erb_factory.rb, line 49 def get_rails_controller_template(is_full) if is_full RSpecKickstarter::ERBTemplates::RAILS_CONTROLLER_NEW_SPEC_TEMPLATE else RSpecKickstarter::ERBTemplates::RAILS_CONTROLLER_METHODS_PART_TEMPLATE end end
get_rails_helper_template(is_full)
click to toggle source
# File lib/rspec_kickstarter/erb_factory.rb, line 57 def get_rails_helper_template(is_full) if is_full RSpecKickstarter::ERBTemplates::RAILS_HELPER_NEW_SPEC_TEMPLATE else RSpecKickstarter::ERBTemplates::RAILS_HELPER_METHODS_PART_TEMPLATE end end