aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Ogata <george.ogata@gmail.com>2009-08-30 23:46:48 -0400
committerMichael Koziarski <michael@koziarski.com>2009-10-15 11:01:42 +1300
commit3de8b44b26ecb64dc73661deb8dde1c5de92b496 (patch)
tree46604dcaae7d67dfe2a193a9e844328745bce860
parent316f4704eaa8aaba11e7ecebc1da9aa926fdd2d0 (diff)
downloadrails-3de8b44b26ecb64dc73661deb8dde1c5de92b496.tar.gz
rails-3de8b44b26ecb64dc73661deb8dde1c5de92b496.tar.bz2
rails-3de8b44b26ecb64dc73661deb8dde1c5de92b496.zip
Make IntegrationTest::Runner propagate method_missing to ancestors.
Fixes RSpec integration example groups, which mixes its Matchers module into ActiveSupport::TestCase. Signed-off-by: Michael Koziarski <michael@koziarski.com>
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb8
-rw-r--r--actionpack/test/controller/integration_test.rb18
2 files changed, 24 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 2c4a3a356d..58ebe94a5b 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -396,8 +396,12 @@ module ActionDispatch
# Delegate unhandled messages to the current session instance.
def method_missing(sym, *args, &block)
reset! unless @integration_session
- returning @integration_session.__send__(sym, *args, &block) do
- copy_session_variables!
+ if @integration_session.respond_to?(sym)
+ returning @integration_session.__send__(sym, *args, &block) do
+ copy_session_variables!
+ end
+ else
+ super
end
end
end
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 508364d0b5..fe95fb5750 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -199,6 +199,24 @@ class IntegrationTestTest < Test::Unit::TestCase
assert_equal ::ActionController::Integration::Session, session2.class
assert_not_equal session1, session2
end
+
+ # RSpec mixes Matchers (which has a #method_missing) into
+ # IntegrationTest's superclass. Make sure IntegrationTest does not
+ # try to delegate these methods to the session object.
+ def test_does_not_prevent_method_missing_passing_up_to_ancestors
+ mixin = Module.new do
+ def method_missing(name, *args)
+ name.to_s == 'foo' ? 'pass' : super
+ end
+ end
+ @test.class.superclass.__send__(:include, mixin)
+ begin
+ assert_equal 'pass', @test.foo
+ ensure
+ # leave other tests as unaffected as possible
+ mixin.__send__(:remove_method, :method_missing)
+ end
+ end
end
# Tests that integration tests don't call Controller test methods for processing.