rubocop-rspec
rubocop-rspec copied to clipboard
Code style checking for RSpec files
I've just upgraded to the latest gem so ran into this. The `Capybara/FeatureMethods` cop suggests that `scenario 'with OAuth'` should be changed to `it 'with OAuth'`. I feel this is...
I will generally use `allow` for setup: ```ruby before do allow(foo).to receive(:bar).and_return(:baz) end ``` and assertion: ```ruby it { expect(foo).to receive(:bar) } ``` If this makes sense, it could make...
When someone uses `stub_const('Foo::BAZ', 42)`, all other constants (and methods) defined in Foo may be lost. This is explained in https://github.com/rspec/rspec-mocks/issues/1079. I've lost couple of hours debugging it the first...
We organize tests in (1 level) nested describes like this: ``` describe User do describe 'validations do' it { ... } end end ``` It would be nice if there...
I wonder if it would be feasible to checking for stubbing the SUT even when `subject` isn't used, e.g.: ``` it "..." do loan = Foo.new allow(loan).to receive(:bar).and_return(:baz) expect(loan.bar).to eq(:baz)...
We had a spec file where we were asserting against an oracle. Then, we discovered issues with the values themselves, so we switched to string interpolation. Unfortunately, with the string...
Related issue: https://github.com/rubocop/rubocop-rspec/issues/1928 Previously you would first get: ``` Error: The `RSpec/Rails/InferredSpecType` cop has been moved to `RSpecRails/InferredSpecType`. (obsolete configuration found in .rubocop.yml, please update it) ``` Then after renaming...
Given this code: ```rb describe "Something" do let(:something_unrelated) { "i exist" } subject(:named_subject) { 1 } subject do 2 end it "should be 2" do expect(subject).to eq(2) end end ```...
If a context only has one example, then the `before` setup can be inlined in the example, since there is no longer any need to extract out common behaviour. Some...
I noticed that when using RuboCop with Code Climate's browser extension, warnings have a toggle which gives helpful details, e.g.: ![screen shot 2017-01-04 at 11 00 56 pm](https://cloud.githubusercontent.com/assets/13400/21668646/d36e491a-d2d1-11e6-9e27-551944d3a3e8.png) It would...