Sha256: 175c2efa7da8a324ce82f2b09edc89cd6770b52700378ff3adb2b1a3a98e1c8f

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require "rspec/rails"
require "rails/generators/test_case"
require "fileutils"
require "generator_spec/matcher"

module GeneratorSpec
  module TestCase
    extend ActiveSupport::Concern
    include RSpec::Rails::RailsExampleGroup
    include Matcher
    include FileUtils
  
    included do
      cattr_accessor :test_case, :test_case_instance
      self.test_case = Class.new(Rails::Generators::TestCase)
      self.test_case.tests subject.call.class
      self.test_case_instance = self.test_case.new(:test)
    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
  
    module InstanceMethods
      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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generator_spec-0.8.0 lib/generator_spec/test_case.rb