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

FactoryBot has an [enum traits](https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#enum-traits) feature that given a model: ```ruby class Task < ActiveRecord::Base enum status: {queued: 0, started: 1, finished: 2} end ``` makes the following definitions redundant:...

cop

I recently wrote something like this in a spec: ```ruby expect(foo.class).to be(Foo) ``` and then it occurred to me that I could use ```ruby expect(foo).to be_an_instance_of(Foo) ``` If it makes...

cop

On RSpec one can do: ```ruby expect { ... }.to change { ... } .and change { ... } ``` But it is not possible to do ```ruby expect {...

enhancement

I have played recently with ScatteredLet autocorrects and noticed a couple of things. First, it moves everything after the first let, which changes the order of lets. It would be...

enhancement

If a test checks few attributes in a row, it probably deserve to use `have_attributes` bad: ```ruby expect(obj.foo).to eq(bar) expect(obj.fu).to eq(bax) expect(obj.name).to eq(baz) ``` good: ``` expect(obj).to have_attributes( foo: bar,...

cop

```ruby RSpec.describe 'Foo' do context 'when bar' do let(:qux) { 111 } let(:unique) { 'no one like me' } before { setup(qux, unique) } it { is_expected.to eq 222 }...

cop

#994 would be the 5th cop that deals with repeated usage, and all the cops share similar structure for the detection: node.children.select { ... }.group_by { .... }.values.reject(&:one?).flat_map { repeated_lines...

The `Inject.defaults!` code is duplicated across many third party gems - [lib/rubocop/rspec/inject.rb@`d25070`](https://github.com/backus/rubocop-rspec/blob/d25070ee09377c99600ac75937f0c503c5b45ee6/lib/rubocop/rspec/inject.rb) - [lib/rubocop/devtools/inject.rb@`fefa8d`](https://github.com/backus/rubocop-devtools/blob/fefa8db5fc1fd95d9ccddff19f98579bfccd9bc1/lib/rubocop/devtools/inject.rb) - [lib/rubocop/cask/inject.rb@`c2456c`](https://github.com/caskroom/rubocop-cask/blob/c2456cdc517c302d8242a1da8f4c2b3a15b23d38/lib/rubocop/cask/inject.rb) - [lib/rubocop/yast/config.rb@`0cdddc`](https://github.com/yast/rubocop-yast/blob/0cdddc26bead94730322dbf4d99f8002318082f0/lib/rubocop/yast/config.rb) This code (plus a few other pieces of rubocop-rspec) would probably benefit...

maintenance
refactor

I noticed that @bbatsov added three commits, adding some AsciiDoc documentation: - 0d5031744078ab0787e0f92ff18828743daf6b69 - b15eefbf3d2e7261c38d30637e0eec36620bb055 - 97e8ebbac60845f83eab72d2cf2851a5c629fbb7 I cannot find any related PRs, so probably they were pushed directly to...

Typically, [models](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/model-specs), [controllers](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/controller-specs), [jobs](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/job-specs/job-spec), [channels](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/channel-specs/channel-spec), [generators](https://github.com/rspec/rspec-rails/blob/main/lib/generators/rspec/generator/templates/generator_spec.rb), [mailboxes](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/mailbox-specs/action-mailbox-spec), [mailers](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/mailer-specs) and [helpers](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/helper-specs/helper-spec) have their classes. Is there a good reason to ignore them in `RSpec/DescribeClass` and not insist on putting the class,...

bug
question