elastic / elastic/logstash

Refactor usage to rspec raise_error match to prevent false positive.

Open
#7,148 0 comments 0 reactions 0 assignees View on GitHub
code cleanup
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

Some of our tests use the `raise_error` matcher without any argument or regular expression to match explicitely match the response. This mean our tests could provide false positive because an expected exception could be raised.

Example from https://github.com/elastic/logstash/blob/0020c4beabdde7e34e895c323a2081a4c3335c4f/logstash-core/spec/logstash/settings_spec.rb#L16

```ruby
it "should raise an exception" do
expect { subject.register(numeric_setting) }.to raise_error
end
```
Need to something like this:
```
it "should raise an exception" do
expect { subject.register(numeric_setting) }.to raise_error ArgumentError, /..../
end
```

With the upgrade to rspec 3.4 this code smell in the suite is exposed, I've silenced them to have the previous behavior but we need to fix them.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.