-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge cases in Minitest/EmptyLineBeforeAssertionMethods
#189
Comments
Similarly, in this case: test "i18n load path yaml files are formatted properly" do
yaml_load_paths.each do |path|
YAML.load_file(path)
rescue Psych::Exception => e
flunk("Error loading #{path}: #{e.inspect}")
end
end I would not expect |
To clarify @movermeyer's comment, that test generates this offense:
|
Fixes part of rubocop#189. This PR fixes a false negative for `Minitest/EmptyLineBeforeAssertionMethods` when using non assertion method statement before assertion method used in a block.
Fixes part of rubocop#189. This PR fixes a false negative for `Minitest/EmptyLineBeforeAssertionMethods` when using non assertion method statement before assertion method used in a block.
Follow up rubocop#189 (comment). This PR fixes a false positive for `Minitest/EmptyLineBeforeAssertionMethods` when using `rescue` before assertion method.
…ssertionMethods` Fixes rubocop#189 and rubocop#194. This PR fixes a false negative for `Minitest/EmptyLineBeforeAssertionMethods` when using assertion method used in block before assertion method.
…ty_line_before_assertion_methods [Fix #189] Fix a false positive for `Minitest/EmptyLineBeforeAssertionMethods`
With rubocop-minitest 0.31.1 I'm still getting a false positive for Minitest/EmptyLineBeforeAssertionMethods on this code for the require "minitest/autorun"
require "set"
class FooTest < MiniTest::Spec
def test_bar
set = Set.new([1,2,3])
set.each do |thing|
refute_nil(thing)
end
end
end |
@MatzFan It looks like it's an expected behavior and doesn't have a false positive: If you have different intentions regarding the above test, please open a new issue based on the template. Thank you. |
Apologies, my mistake in not realizing I need to put a space before the block containing an assertion. Sorry for the false negative! |
The
Minitest/EmptyLineBeforeAssertionMethods
cop has some behaviors related to blocks (like#each
loops) that I think either result in unnecessary warnings or missed warnings.Example
Actual behavior
Expected behavior
In
test_foo
, I do expect the warning on line 7, but I do not expect the warning on line 11.In
test_bar
, I would expect a warning to appear before theset.each
line.In situations like this, I expect that a block containing only assertions should be treated as if it was an assertion.
RuboCop version
The text was updated successfully, but these errors were encountered: