Skip to content

Commit

Permalink
Fix incorrect usage of rspec raise_error
Browse files Browse the repository at this point in the history
WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass)`
 risks false positives, since literally any other error would cause
 the expectation to pass, including those raised by Ruby
 (e.g. NoMethodError, NameError and ArgumentError), meaning the code
 you are intending to test may not even get reached. Instead consider
 using `expect { }.not_to raise_error` or
 `expect { }.to raise_error(DifferentSpecificErrorClass)`.
  • Loading branch information
BobbyMcWho committed Sep 28, 2019
1 parent 1c4d8a3 commit 429f899
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec/faraday/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
end

it 'allows backward-compatible class to be subclassed' do
expect { class CustomError < Faraday::Error::ClientError; end }.not_to raise_error(TypeError)
expect { class CustomError < Faraday::Error::ClientError; end }.not_to raise_error
end
end

Expand Down

0 comments on commit 429f899

Please sign in to comment.