Sha256: 258d397165a1f1d4f99f727ce17b1192aca4691e0ffaa39d8dfbbba4a22b2a6a
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
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 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 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 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 } 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) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ammeter-0.0.3 | lib/ammeter/rspec/generator/example/generator_example_group.rb |