module Draper
  module DecoratorExampleGroup
    extend ActiveSupport::Concern
    included { metadata[:type] = :decorator }
  end

  RSpec.configure do |config|
    # Automatically tag specs in specs/decorators as type: :decorator
    config.include Draper::DecoratorExampleGroup, :type => :decorator, :example_group => {
      :file_path => /spec[\\\/]decorators/
    }

    # Specs tagged type: :decorator set the Draper view context
    config.around do |example|
      if :decorator == example.metadata[:type]
        ApplicationController.new.set_current_view_context
      end
      example.call
    end
  end
end

module Draper
  module DecoratorExampleGroup
    extend ActiveSupport::Concern
    included { metadata[:type] = :decorator }
  end

  RSpec.configure do |config|
    # Automatically tag specs in specs/decorators as type: :decorator
    config.include Draper::DecoratorExampleGroup, :type => :decorator, :example_group => {
      :file_path => /spec[\\\/]decorators/
    }

    # Specs tagged type: :decorator set the Draper view context
    config.around do |example|
      if :decorator == example.metadata[:type]
        ApplicationController.new.set_current_view_context
        Draper::ViewContext.current.controller.request ||= ActionController::TestRequest.new
        Draper::ViewContext.current.request            ||= Draper::ViewContext.current.controller.request
        Draper::ViewContext.current.params             ||= {}
      end
      example.call
    end
  end
end

Add request and params support to the Draper spec harness
Add request and params support to the Draper spec harness
