Specs at spec/decorators prime the view context
This commit is contained in:
parent
78b200a84f
commit
a5a3c38770
|
@ -6,5 +6,6 @@ require 'draper/model_support'
|
|||
require 'draper/helper_support'
|
||||
require 'draper/view_context'
|
||||
require 'draper/decorated_enumerable_proxy'
|
||||
require 'draper/rspec_integration' if defined?(RSpec)
|
||||
|
||||
Draper::System.setup
|
||||
Draper::System.setup
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
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
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ApplicationDecorator do
|
||||
before { ApplicationController.new.set_current_view_context }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue