Sha256: 28ecc6001a9ff99325d0e85024516d30d78d23cc899cb1137f997f9292c9f1a2

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
lurker-0.6.6 lib/lurker/spec_helper/rails.rb
lurker-0.6.5 lib/lurker/spec_helper/rails.rb
lurker-0.6.4 lib/lurker/spec_helper/rails.rb
lurker-0.6.3 lib/lurker/spec_helper/rails.rb
lurker-0.6.2 lib/lurker/spec_helper/rails.rb
lurker-0.6.1 lib/lurker/spec_helper/rails.rb
lurker-0.5.7 lib/lurker/spec_helper/rails.rb
lurker-0.6.0 lib/lurker/spec_helper/rails.rb