mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
parent
8b0b50e494
commit
57c8678e8c
1 changed files with 23 additions and 14 deletions
|
@ -3,22 +3,31 @@ module Draper
|
|||
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/
|
||||
}
|
||||
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
|
||||
# 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
|
||||
|
||||
|
|
Loading…
Reference in a new issue