Sha256: fb1ce5f1b3c4214fb2c4e1c162fd3e52f45d5e8666b450e6597a05a4eca0d676

Contents?: true

Size: 1015 Bytes

Versions: 6

Compression:

Stored size: 1015 Bytes

Contents

module Draper
  module DecoratorExampleGroup
    extend ActiveSupport::Concern
    included { metadata[:type] = :decorator }
  end
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

if defined?(Capybara)
  require 'capybara/rspec/matchers'

  RSpec.configure do |config|
    config.include Capybara::RSpecMatchers, :type => :decorator
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
draper-0.14.0 lib/draper/rspec_integration.rb
draper-0.12.3 lib/draper/rspec_integration.rb
draper-0.12.2 lib/draper/rspec_integration.rb
draper-0.13.0 lib/draper/rspec_integration.rb
draper-0.12.1 lib/draper/rspec_integration.rb
draper-0.12.0 lib/draper/rspec_integration.rb