1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Adding capybara integration.

Fixes #156
This commit is contained in:
Steve Klabnik 2012-05-09 14:29:32 -04:00
parent 8b0b50e494
commit 57c8678e8c

View file

@ -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