rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Code style checking for RSpec files

Results 163 rubocop-rspec issues
Sort by recently updated
recently updated
newest added

Just upgraded and came across the new `StubbedMock` rule. I'd love to have a configuration that inverts the rule and prefers `expect` over `allow`. The reason for this is that...

See: https://github.com/rubocop-hq/rubocop-rspec/blob/137dc91ba422d701eed88a121275dbdec182a180/lib/rubocop/cop/rspec/file_path.rb#L75-L79 For example, consider the following: ``` # spec/requests/bad_filename_format.rb RSpec.describe "Some really cool tests" do # ... end ``` Because a _constant_ was not defined (i.e. the test description...

When I initially implemented the cop, I left the case when someone uses (1..n).each {} and added check only for `.times` iteration. I feel now it's the time to improve...

enhancement

`RSpec/PredicateMatcher` tells me to prefer the first form to the second one: ```ruby context 'given some result' do let(:error) { 'Oops, a few things blew up and nothing worked' }...

enhancement
Discussion

Before submitting the PR make sure the following are checked: * [x] Feature branch is up-to-date with `master` (if not - rebase it). * [x] Squashed related commits together. *...

This adds `named_only` style for the RSpec/NamedSubject cop. It is intended as a smaller step to first catch explicit subject references where the `subject(:name) { .. }` is named. We...

Prevents persistence calls from being called outside example or hook. https://github.com/rubocop-hq/rubocop-rspec/issues/991 --- Before submitting the PR make sure the following are checked: * [x] Feature branch is up-to-date with `master`...

On [this source file](https://github.com/marcandre/rubocop-ast/blob/rspec_bug/spec/rubocop/ast/node_pattern_spec.rb) ```sh # running: > rubocop -A spec/rubocop/ast/node_pattern_spec.rb --only RSpec/LetBeforeExamples,RSpec/ScatteredLet Inspecting 1 file C Offenses: spec/rubocop/ast/node_pattern_spec.rb:1632:9: C: [Corrected] RSpec/LetBeforeExamples: Move let before the examples in the group....

bug

Hi, we have a shared context that we include, that defines it's own `subject`. Reason behind is, that we have many models, that need the same test setup and only...

A common mistake I see is using closure variables instead of let statements. An example of this: ```ruby describe User do user = FactoryBot.create(:user) it "exists" do expect(user).not_to be_nil end...

cop