Specs at spec/decorators prime the view context

This commit is contained in:
Duncan Beevers 2011-11-28 20:04:38 -06:00
parent 78b200a84f
commit a5a3c38770
3 changed files with 24 additions and 2 deletions

View File

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

View File

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

View File

@ -1,5 +1,4 @@
require 'spec_helper'
describe ApplicationDecorator do
before { ApplicationController.new.set_current_view_context }
end