Skip to content

Commit

Permalink
fix patch for rails3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
razum2um committed May 14, 2014
1 parent da42b90 commit f6fe5b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Lurker
module SpecWatcher
module ActionDispatchHook
module Rails
extend ActiveSupport::Concern

module ClassMethods
Expand Down Expand Up @@ -32,9 +32,9 @@ def new(*)
end

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

if defined?(ActionController::TestCase::Behavior)
ActionController::TestCase::Behavior.send :include, Lurker::SpecWatcher::ActionDispatchHook
ActionController::TestCase::Behavior.send :include, Lurker::SpecWatcher::Rails
end
9 changes: 5 additions & 4 deletions lib/lurker/spec_watcher/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ module Rspec
request_params ||= {}
env ||= {}

if action.is_a?(Symbol)
# obsolete, support controller -> request migration
# supports `get :index` in request specs
if @_example && @_example.metadata[:type] == :request && action.is_a?(Symbol)
unless @_example.metadata.described_class.is_a?(Class)
raise 'cannot determine request url: provide proper described class like: "describe MyController do"'
end
Expand All @@ -28,6 +30,7 @@ module Rspec
begin
send :alias_method_chain, verb, :lurker
rescue NameError
# no patch in Rails3.2
if verb == :patch
alias_method :patch_without_lurker, :put_without_lurker
alias_method :patch, :patch_with_lurker
Expand All @@ -43,15 +46,13 @@ module Rspec

if defined?(RSpec)
RSpec.configure do |config|
# obsolete, support controller -> request migration
# supports `get :index` in request specs
config.include Lurker::SpecWatcher::Rspec, type: :controller
config.include Lurker::SpecWatcher::Rspec, type: :request

lurker = ->(example) {
# RSpec::Core::ExampleGroup::Nested_1 === self
@_example = example

#binding.pry
if (metadata = example.metadata[:lurker]).present?
Lurker::Spy.on(suffix: metadata, &example)
else
Expand Down

0 comments on commit f6fe5b7

Please sign in to comment.