Sha256: dbf29cc587fc96e121f7b3ec8581a66e60bfe95d74c6b6193407b2bf63512759

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'active_support/concern'
require 'lurker/spy'

module Lurker
  module SpecHelper
    module Rails
      extend ActiveSupport::Concern

      module ClassMethods
        module LurkerSession
          def process(*)
            super.tap do
              if Lurker::Spy.enabled?
                [:@request, :@response].each do |iv_name|
                  if !instance_variable_defined?(iv_name) || instance_variable_get(iv_name).nil?
                    raise Lurker::Spy::BlindError.new("#{iv_name} is nil: make sure you set it in your test's setup method.")
                  end
                end

                Lurker::Spy.current.request  = Lurker::Request.build_from_action_dispatch(@request)
                Lurker::Spy.current.response = Lurker::Response.build_from_action_dispatch(@response)
              end
            end
          end
        end

        def new(*)
          super.extend(LurkerSession)
        end
      end
    end
  end
end

if defined?(ActionDispatch::Integration::Session)
  ActionDispatch::Integration::Session.send :include, Lurker::SpecHelper::Rails
end

if defined?(ActionController::TestCase::Behavior)
  ActionController::TestCase::Behavior.send :include, Lurker::SpecHelper::Rails
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lurker-1.0.0 lib/lurker/spec_helper/rails.rb
lurker-0.6.12 lib/lurker/spec_helper/rails.rb
lurker-0.6.11 lib/lurker/spec_helper/rails.rb
lurker-0.6.10 lib/lurker/spec_helper/rails.rb
lurker-0.6.9 lib/lurker/spec_helper/rails.rb
lurker-0.6.8 lib/lurker/spec_helper/rails.rb
lurker-0.6.7 lib/lurker/spec_helper/rails.rb