Skip to content

Commit

Permalink
fixup! remove unnecessary flagging of be without args
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Jan 15, 2020
1 parent 701ccfe commit 7349a8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
8 changes: 1 addition & 7 deletions lib/rubocop/cop/rspec/expect_actual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExpectActual < Cop
#{Runners::ALL.node_pattern_union}
{
(send (send nil? $:be) :== $_)
(send nil? $:be $...)
(send nil? $:be $_)
(send nil? $_ $_ ...)
}
)
Expand All @@ -66,12 +66,6 @@ def autocorrect(node)
lambda do |corrector|
return unless SUPPORTED_MATCHERS.include?(matcher)

if expected.is_a?(Array)
return if expected.none? # `be` without args

expected = expected.first
end

swap(corrector, actual, expected)
end
end
Expand Down
9 changes: 3 additions & 6 deletions spec/rubocop/cop/rspec/expect_actual_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,14 @@
RUBY
end

it 'flags `be` with no argument' do
expect_offense(<<~RUBY)
it 'ignores `be` with no argument' do
expect_no_offenses(<<~RUBY)
describe Foo do
it 'uses expect incorrectly' do
it 'uses expect legitimately' do
expect(1).to be
^ Provide the actual you are testing to `expect(...)`.
end
end
RUBY

expect_no_corrections
end

it 'flags `be` with an argument' do
Expand Down

0 comments on commit 7349a8a

Please sign in to comment.