lib/draper/test/rspec_integration.rb in draper-1.0.0.beta6 vs lib/draper/test/rspec_integration.rb in draper-1.0.0
- old
+ new
@@ -1,67 +1,12 @@
module Draper
module DecoratorExampleGroup
+ include Draper::TestCase::Behavior
extend ActiveSupport::Concern
+
included { metadata[:type] = :decorator }
end
- module DeviseHelper
- def sign_in(user)
- warden.stub :authenticate! => user
- controller.stub :current_user => user
- user
- end
-
- private
-
- def request
- @request ||= ::ActionDispatch::TestRequest.new
- end
-
- def controller
- return @controller if @controller
- @controller = ApplicationController.new
- @controller.request = request
- ::Draper::ViewContext.current = @controller.view_context
- @controller
- end
-
- # taken from Devise's helper but uses the request method instead of @request
- # and we don't really need the rest of their helper
- def warden
- @warden ||= begin
- manager = Warden::Manager.new(nil) do |config|
- config.merge! Devise.warden_config
- end
- request.env['warden'] = Warden::Proxy.new(request.env, manager)
- end
- end
+ RSpec.configure do |config|
+ config.include DecoratorExampleGroup, example_group: {file_path: %r{spec/decorators}}, 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/
- }
-
- if defined?(Devise)
- config.include Draper::DeviseHelper, :type => :decorator
- end
-end
-
-module Draper
- module RSpec
- class Railtie < Rails::Railtie
- config.after_initialize do |app|
- if defined?(Capybara)
- require 'capybara/rspec/matchers'
-
- ::RSpec.configure do |config|
- config.include Capybara::RSpecMatchers, :type => :decorator
- end
- end
- end
- end
- end
-end
-