Skip to content

Commit

Permalink
Disable Style/Semicolon cop globally
Browse files Browse the repository at this point in the history
This is useful when using `ExecutionPoint.current` to make tests more
robust.
  • Loading branch information
floehopper committed Oct 18, 2022
1 parent 9cd08be commit 8cd0b70
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Style/WhileUntilModifier:
Style/AccessModifierDeclarations:
Enabled: false

# This is useful when using `ExecutionPoint.current` to make tests more robust
Style/Semicolon:
Enabled: false

# Enabling this cop results in an "Infinite loop detected" exception
Layout/AccessModifierIndentation:
Enabled: false
Expand Down
2 changes: 0 additions & 2 deletions test/acceptance/mocha_test_result_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_should_include_assertion_failure_in_failure_count
assert_equal 1, test_result.failure_count
end

# rubocop:disable Style/Semicolon
def test_should_display_backtrace_indicating_line_number_where_unexpected_method_was_called
execution_point = nil
test_result = run_as_test do
Expand All @@ -79,5 +78,4 @@ def test_should_display_backtrace_indicating_line_number_where_failing_assertion
assert_equal 1, test_result.failure_count
assert_equal execution_point, ExecutionPoint.new(test_result.failures[0].location)
end
# rubocop:enable Style/Semicolon
end
2 changes: 0 additions & 2 deletions test/acceptance/stubba_test_result_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def test_should_include_assertion_failure_in_failure_count
assert_equal 1, test_result.failure_count
end

# rubocop:disable Style/Semicolon
def test_should_display_backtrace_indicating_line_number_where_failing_assertion_was_called
execution_point = nil
test_result = run_as_test do
Expand All @@ -67,5 +66,4 @@ def test_should_display_backtrace_indicating_line_number_where_failing_assertion
assert_equal 1, test_result.failure_count
assert_equal execution_point, ExecutionPoint.new(test_result.failures[0].location)
end
# rubocop:enable Style/Semicolon
end
2 changes: 0 additions & 2 deletions test/acceptance/stubbing_error_backtrace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def teardown
teardown_acceptance_test
end

# rubocop:disable Style/Semicolon
def test_should_display_backtrace_indicating_line_number_where_attempt_to_stub_non_existent_method_was_made
execution_point = nil
object = Object.new
Expand Down Expand Up @@ -59,5 +58,4 @@ def test_should_display_backtrace_indicating_line_number_where_method_was_unnece
assert_errored(test_result)
assert_equal execution_point, ExecutionPoint.new(test_result.errors[0].exception.backtrace)
end
# rubocop:enable Style/Semicolon
end
2 changes: 0 additions & 2 deletions test/acceptance/stubbing_frozen_object_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def teardown
teardown_acceptance_test
end

# rubocop:disable Style/Semicolon
def test_should_fail_fast_if_attempting_to_stub_method_on_frozen_object
object = Object.new
object.freeze
Expand Down Expand Up @@ -78,5 +77,4 @@ def test_should_fail_fast_if_attempting_to_expect_method_on_any_instance_of_froz
assert_errored(test_result)
assert_equal execution_point, ExecutionPoint.new(test_result.errors[0].exception.backtrace)
end
# rubocop:enable Style/Semicolon
end
2 changes: 0 additions & 2 deletions test/integration/shared_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_assertion_satisfied
assert_passed(test_result)
end

# rubocop:disable Style/Semicolon
def test_assertion_unsatisfied
execution_point = nil
test_result = run_as_test do
Expand Down Expand Up @@ -173,6 +172,5 @@ def test_real_object_expectation_does_not_leak_into_subsequent_test
assert_equal execution_point, ExecutionPoint.new(exception.backtrace)
assert_match(/undefined method `foo'/, exception.message)
end
# rubocop:enable Style/Semicolon
end
# rubocop:enable Metrics/ModuleLength
4 changes: 0 additions & 4 deletions test/unit/expectation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ def test_should_store_provided_backtrace
assert_equal backtrace, Expectation.new(nil, :expected_method, backtrace).backtrace
end

# rubocop:disable Style/Semicolon
def test_should_default_backtrace_to_caller
execution_point = ExecutionPoint.current; expectation = Expectation.new(nil, :expected_method)
assert_equal execution_point, ExecutionPoint.new(expectation.backtrace)
end
# rubocop:enable Style/Semicolon

def test_should_not_yield
yielded = false
Expand Down Expand Up @@ -312,12 +310,10 @@ def test_should_not_increment_assertion_counter_for_stub_because_it_does_not_nee
assert_equal 0, assertion_counter.count
end

# rubocop:disable Style/Semicolon
def test_should_store_backtrace_from_point_where_expectation_was_created
execution_point = ExecutionPoint.current; expectation = Expectation.new(nil, :expected_method)
assert_equal execution_point, ExecutionPoint.new(expectation.backtrace)
end
# rubocop:enable Style/Semicolon

class FakeMock
def initialize(name)
Expand Down

0 comments on commit 8cd0b70

Please sign in to comment.