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

We have some spec files which are isolated by their metadata. For example, specs for services which touch real APIs using test accounts. We want them to be completely isolated...

Continuing https://github.com/rubocop/rubocop-rspec/issues/879. We're using `rspec-its` and have examples like this: ```ruby describe Service do describe 'returned values' do subject { service } before { service.call } its(:model) { is_expected.not_to be_valid...

bug

Implement a new cop that enables the enforcement of parentheses in factory bot calls. This cop attempts to solve the "issue" outlined in #416 edit: fixes #416 --- Before submitting...

When dealing with APIs it's often required to stub multiple messages. Instead of having: ``` before do allow(Service).to receive(:retrieve).and_return(resource) allow(Service).to receive(:create).and_return(resource) allow(Service).to receive(:update).and_return(updated_resource) end ``` We could have a spec...

cop

I often see checks on message expectations like ``` expect(subject.foo).to raise_error(Error) do |error| expect(error.message).to match(/..../) end ``` while `raise_error` offers `.with_message`

cop

The `have_*` collection of capybara matchers has the same set of `have_no` matches, for checking that there is no content matching. This creates the option to write the expectation in...

cop

FactoryBot actually has a few more `list` methods than just `create_list`: ```ruby 3.0.2 :006 > pp FactoryBot::Syntax::Methods.instance_methods.sort [:attributes_for, :attributes_for_list, :attributes_for_pair, :build, :build_list, :build_pair, :build_stubbed, :build_stubbed_list, :build_stubbed_pair, :create, :create_list, :create_pair, :generate,...

I am trying to use RSpec aggregate_failures to speed up my specs, but `rubocop-rspec` complains that my example now has too many lines because I have 8 expectations. Is this...

enhancement

Idea for cop suggestion: Prefer `expect(subject).to eq(true)` not `expect(subject).to(eq(true))`. The same when `not_to` so `expect(subject).not_to eq(true)` not `expect(subject).not_to(eq(true))`. There's no single example where second approach is being used in https://github.com/rubocop-hq/rspec-style-guide.