mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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>
This commit is contained in:
parent
316f4704ea
commit
3de8b44b26
2 changed files with 24 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue