Sha256: 60911ec881fe721476288275cf9699f8ca387f68bf8f3b5a66a2728c247c6bf8

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'active_record'
require 'rails/generators/test_case'
require 'generator_spec/matcher'

module GeneratorSpec
  module TestCase
    extend ActiveSupport::Concern
    include Matcher
    include FileUtils

    included do
      cattr_accessor :test_case, :test_case_instance

      self.test_case = Class.new(Rails::Generators::TestCase) do
        def fake_test_case; end
        def add_assertion; end
      end
      self.test_case_instance = self.test_case.new(:fake_test_case)
      self.test_case.tests described_class
    end

    module ClassMethods
      def tests(klass)
        self.test_case.generator_class = klass
      end

      def arguments(array)
        self.test_case.default_arguments = array
      end

      def destination(path)
        self.test_case.destination_root = path
      end
    end

    def method_missing(method_sym, *arguments, &block)
      self.test_case_instance.send(method_sym, *arguments, &block)
    end

    def respond_to?(method_sym, include_private = false)
      if self.test_case_instance.respond_to?(method_sym)
        true
      else
        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
generator_spec-0.9.0 lib/generator_spec/test_case.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/generator_spec-0.8.7/lib/generator_spec/test_case.rb
generator_spec-0.8.7 lib/generator_spec/test_case.rb