Module: Ammeter::RSpec::Rails::GeneratorExampleGroup

Extended by:
ActiveSupport::Concern
Includes:
RSpec::Rails::RailsExampleGroup
Defined in:
lib/ammeter/rspec/generator/example/generator_example_group.rb

Overview

Delegates to Rails::Generators::TestCase to work with RSpec.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DELEGATED_METHODS =
[:destination_root, :current_path, :generator_class]

Instance Method Summary collapse

Instance Method Details

#file(relative) ⇒ Object



76
77
78
# File 'lib/ammeter/rspec/generator/example/generator_example_group.rb', line 76

def file relative
  File.expand_path(relative, destination_root)
end

#invoke_task(name) ⇒ Object



49
50
51
# File 'lib/ammeter/rspec/generator/example/generator_example_group.rb', line 49

def invoke_task name
  OutputCapturer.capture(:stdout) { generator.invoke_task(generator_class.all_tasks[name.to_s]) }
end

#migration_file(relative) ⇒ Object



79
80
81
82
83
84
# File 'lib/ammeter/rspec/generator/example/generator_example_group.rb', line 79

def migration_file relative
  file_path = file(relative)
  migration_file = Dir.glob("#{File.dirname(file_path)}/[0-9]*_#{File.basename(file_path)}").first
  migration_file = "#{File.dirname(file_path)}/TIMESTAMP_#{File.basename(file_path)}" if migration_file.nil?
  migration_file
end

#subjectObject



85
86
87
# File 'lib/ammeter/rspec/generator/example/generator_example_group.rb', line 85

def subject
  generator
end