From 8f6a9b494d34dcbd13e4671e9225c6a99c0c715b Mon Sep 17 00:00:00 2001 From: Nitish Rathi Date: Wed, 15 Jan 2020 15:20:45 +0000 Subject: [PATCH] use StubbingPublicMethodIsAllowed in StubbingExistingMethodIsAllowed --- .../stubbing_existing_method_is_allowed.rb | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/test/acceptance/stubbing_existing_method_is_allowed.rb b/test/acceptance/stubbing_existing_method_is_allowed.rb index c1a6cb632..74f8c51e0 100644 --- a/test/acceptance/stubbing_existing_method_is_allowed.rb +++ b/test/acceptance/stubbing_existing_method_is_allowed.rb @@ -1,19 +1,7 @@ -require File.expand_path('../acceptance_test_helper', __FILE__) +require File.expand_path('../stubbing_public_method_is_allowed', __FILE__) module StubbingExistingMethodIsAllowed - include AcceptanceTest - - def setup - setup_acceptance_test - end - - def teardown - teardown_acceptance_test - end - - def test_should_allow_stubbing_existing_public_method - assert_allows_stubbing_existing_method(:public) - end + include StubbingPublicMethodIsAllowed def test_should_allow_stubbing_existing_protected_method assert_allows_stubbing_existing_method(:protected) @@ -23,28 +11,12 @@ def test_should_allow_stubbing_existing_private_method assert_allows_stubbing_existing_method(:private) end - def test_should_allow_stubbing_method_responded_to - method_owner.send(:define_method, :respond_to?) do |method| - (method == :method_responded_to) - end - assert_allows_stubbing_method(:method_responded_to) - end - def assert_allows_stubbing_existing_method(visibility) method_owner.send(:define_method, :existing_method) {} method_owner.send(visibility, :existing_method) assert_allows_stubbing_method(:existing_method) end - def assert_allows_stubbing_method(stubbed_method) - Mocha.configure { |c| configure_violation(c, :prevent) } - stub_owner_in_scope = stub_owner - test_result = run_as_test do - stub_owner_in_scope.stubs(stubbed_method) - end - assert_passed(test_result) - end - def configure_violation(config, treatment) config.stubbing_non_existent_method = treatment end