lib/ammeter/rspec/generator/example/generator_example_group.rb in ammeter-0.0.3 vs lib/ammeter/rspec/generator/example/generator_example_group.rb in ammeter-0.1.0

- old
+ new

@@ -1,61 +1,65 @@ require 'rails/generators' require 'rspec/rails' -module RSpec::Rails - # Delegates to Rails::Generators::TestCase to work with RSpec. - module GeneratorExampleGroup - extend ActiveSupport::Concern - include RSpec::Rails::RailsExampleGroup +module Ammeter + module RSpec + module Rails + # Delegates to Rails::Generators::TestCase to work with RSpec. + module GeneratorExampleGroup + extend ActiveSupport::Concern + include ::RSpec::Rails::RailsExampleGroup - DELEGATED_METHODS = [:generator, :destination_root_is_set?, :capture, :ensure_current_path, - :prepare_destination, :destination_root, :current_path, :generator_class] - module ClassMethods - mattr_accessor :test_unit_test_case_delegate - delegate :default_arguments, :to => :'self.test_unit_test_case_delegate' - DELEGATED_METHODS.each do |method| - delegate method, :to => :'self.test_unit_test_case_delegate' - end - delegate :destination, :arguments, :to => :'self.test_unit_test_case_delegate.class' + DELEGATED_METHODS = [:generator, :destination_root_is_set?, :capture, :ensure_current_path, + :prepare_destination, :destination_root, :current_path, :generator_class] + module ClassMethods + mattr_accessor :test_unit_test_case_delegate + delegate :default_arguments, :to => :'self.test_unit_test_case_delegate' + DELEGATED_METHODS.each do |method| + delegate method, :to => :'self.test_unit_test_case_delegate' + end + delegate :destination, :arguments, :to => :'self.test_unit_test_case_delegate.class' - def initialize_delegate - self.test_unit_test_case_delegate = Rails::Generators::TestCase.new 'pending' - self.test_unit_test_case_delegate.class.tests(describes) - end + def initialize_delegate + self.test_unit_test_case_delegate = ::Rails::Generators::TestCase.new 'pending' + self.test_unit_test_case_delegate.class.tests(describes) + end - def run_generator(given_args=self.default_arguments, config={}) - args, opts = Thor::Options.split(given_args) - capture(:stdout) { generator(args, opts, config).invoke_all } - end - end + def run_generator(given_args=self.default_arguments, config={}) + args, opts = Thor::Options.split(given_args) + capture(:stdout) { generator(args, opts, config).invoke_all } + end + end - module InstanceMethods - def invoke_task name - capture(:stdout) { generator.invoke_task(generator_class.all_tasks[name.to_s]) } - end - end + module InstanceMethods + def invoke_task name + capture(:stdout) { generator.invoke_task(generator_class.all_tasks[name.to_s]) } + end + end - included do - delegate :run_generator, :destination, :arguments, :to => :'self.class' - DELEGATED_METHODS.each do |method| - delegate method, :to => :'self.class' - end - initialize_delegate + included do + delegate :run_generator, :destination, :arguments, :to => :'self.class' + DELEGATED_METHODS.each do |method| + delegate method, :to => :'self.class' + end + initialize_delegate - subject { generator } + subject { generator } - before do - self.class.initialize_delegate - destination_root_is_set? - ensure_current_path - end - after do - ensure_current_path - end - metadata[:type] = :generator - end + before do + self.class.initialize_delegate + destination_root_is_set? + ensure_current_path + end + after do + ensure_current_path + end + metadata[:type] = :generator + end - def file relative - File.expand_path(relative, destination_root) + def file relative + File.expand_path(relative, destination_root) + end + end end end end \ No newline at end of file