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

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/helper_support'
require 'draper/view_context' require 'draper/view_context'
require 'draper/decorated_enumerable_proxy' require 'draper/decorated_enumerable_proxy'
require 'draper/rspec_integration' if defined?(RSpec)
Draper::System.setup 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' require 'spec_helper'
describe ApplicationDecorator do describe ApplicationDecorator do
before { ApplicationController.new.set_current_view_context }
end end