Sha256: 6502aa4062d34c731c7450270c27d02df6c33abdf5a939ed36d208ae532cb516

Contents?: true

Size: 910 Bytes

Versions: 4

Compression:

Stored size: 910 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/test_case'

module Uploadcare
  module Rails
    module Generators
      extend ActiveSupport::Concern

      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 = test_case.new(:fake_test_case)
        test_case.generator_class = described_class
      end

      def prepare_destination
        test_case_instance.send :prepare_destination
      end

      def run_generator
        test_case_instance.run_generator
      end

      module ClassMethods
        def destination(path)
          test_case.destination_root = path
        end
      end
    end
  end
end

RSpec.configure do |c|
  c.include Uploadcare::Rails::Generators, type: :generator
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uploadcare-rails-3.2.0 spec/support/generators.rb
uploadcare-rails-2.1.1 spec/support/generators.rb
uploadcare-rails-2.1.0 spec/support/generators.rb
uploadcare-rails-2.0.0 spec/support/generators.rb