Skip to content

Commit

Permalink
Refactor: extract configure_violation to reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
nitishr committed Jan 16, 2020
1 parent 9d90336 commit d2932ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion test/acceptance/stubbing_existing_method_is_allowed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ def assert_allows_stubbing_existing_method(visibility)
end

def assert_allows_stubbing_method(stubbed_method)
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
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
end
6 changes: 5 additions & 1 deletion test/acceptance/stubbing_public_method_is_allowed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ def test_should_allow_stubbing_method_responded_to
end

def assert_allows_stubbing_method(stubbed_method)
Mocha.configure { |c| c.stubbing_non_public_method = :prevent }
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_public_method = treatment
end
end

0 comments on commit d2932ce

Please sign in to comment.