Git Product home page Git Product logo

rubocop-rspec's Introduction

RuboCop Logo


Ruby Style Guide Gem Version Actions Status Test Coverage Maintainability Discord

Role models are important.
-- Officer Alex J. Murphy / RoboCop

RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options.


Patreon OpenCollective OpenCollective Tidelift

Working on RuboCop is often fun, but it also requires a great deal of time and energy.

Please consider financially supporting its ongoing development.

Installation

RuboCop's installation is pretty standard:

$ gem install rubocop

If you'd rather install RuboCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem 'rubocop', require: false

RuboCop is stable between minor versions, both in terms of API and cop configuration. We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop releases. All big changes are reserved for major releases. To prevent an unwanted RuboCop update you might want to use a conservative version lock in your Gemfile:

gem 'rubocop', '~> 1.65', require: false

See our versioning policy for further details.

Quickstart

Just type rubocop in a Ruby project's folder and watch the magic happen.

$ cd my/cool/ruby/project
$ rubocop

You can also use this magic in your favorite editor with RuboCop's built-in LSP server.

Documentation

You can read a lot more about RuboCop in its official docs.

Compatibility

RuboCop officially supports the following runtime Ruby implementations:

  • MRI 2.7+
  • JRuby 9.4+

Targets Ruby 2.0+ code analysis.

See the compatibility documentation for further details.

Readme Badge

If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.

Ruby Style Guide

Ruby Style Guide

Here are the Markdown snippets for the two badges:

[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)

[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)

Team

Here's a list of RuboCop's core developers:

See the team page for more details.

Logo

RuboCop's logo was created by Dimiter Petrov. You can find the logo in various formats here.

The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Contributors

Here's a list of all the people who have contributed to the development of RuboCop.

I'm extremely grateful to each and every one of them!

If you'd like to contribute to RuboCop, please take the time to go through our short contribution guidelines.

Converting more of the Ruby Style Guide into RuboCop cops is our top priority right now. Writing a new cop is a great way to dive into RuboCop!

Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-)

Funding

While RuboCop is free software and will always be, the project would benefit immensely from some funding. Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project which would speed up the pace of development significantly.

We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account for your preferences (although currently Open Collective is our preferred funding platform).

If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company to become a RuboCop sponsor.

You can support the development of RuboCop via GitHub Sponsors, Patreon, PayPal, Open Collective and Tidelift .

Note: If doing a sponsorship in the form of donation is problematic for your company from an accounting standpoint, we'd recommend the use of Tidelift, where you can get a support-like subscription instead.

Open Collective Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Open Collective Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Changelog

RuboCop's changelog is available here.

Copyright

Copyright (c) 2012-2024 Bozhidar Batsov. See LICENSE.txt for further details.

rubocop-rspec's People

Contributors

abrom avatar andrykonchin avatar andyw8 avatar backus avatar bquorning avatar darhazer avatar dgollahon avatar dmitrytsepelev avatar fragoulis avatar g-rath avatar geniou avatar harrylewis avatar jawshooah avatar koic avatar kuboon avatar lazycoder9 avatar marcandre avatar marocchino avatar mockdeep avatar nevir avatar nijikon avatar pirj avatar pocke avatar r7kamura avatar rspeicher avatar sl4vr avatar tejasbubane avatar walf443 avatar yasu551 avatar ydah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rubocop-rspec's Issues

Does not work with latest Rubocop 0.25

Here is an error which I get running rubocop -d:

undefined local variable or method `path' for RuboCop::RSpec::Inject:Module
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-rspec-1.1.0/lib/rubocop/rspec/inject.rb:16:in `defaults!'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-rspec-1.1.0/lib/rubocop-rspec.rb:9:in `<top (required)>'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/config_loader.rb:43:in `require'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/config_loader.rb:43:in `block in load_file'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/config_loader.rb:43:in `each'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/config_loader.rb:43:in `load_file'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/config_loader.rb:97:in `configuration_from_file'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/config_store.rb:40:in `for'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/target_finder.rb:59:in `target_files_in_dir'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/target_finder.rb:29:in `find'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/runner.rb:47:in `find_target_files'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/runner.rb:18:in `run'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/lib/rubocop/cli.rb:24:in `run'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/bin/rubocop:13:in `block in <top (required)>'
/Users/kuczynsk/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/gems/rubocop-0.25.0/bin/rubocop:12:in `<top (required)>'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/bin/rubocop:23:in `load'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/bin/rubocop:23:in `<main>'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/bin/ruby_executable_hooks:15:in `eval'
/Users/kuczynsk/.rvm/gems/ruby-2.1.2@izumi/bin/ruby_executable_hooks:15:in `<main>'

Broken in rubocop 0.25

Upgraded to the new rubocop release 0.25; got the following errors:

no implicit conversion of String into Integer
/Users/daniel.heath/Projects/rea/atlas/.bundle/gems/rubocop-rspec-1.1.0/lib/rubocop/cop/rspec/file_name.rb:45:in `[]'
For /Users/daniel.heath/Projects/rea/atlas: configuration from /Users/daniel.heath/Projects/rea/atlas/.rubocop.yml
undefined local variable or method `path' for RuboCop::RSpec::Inject:Module
/Users/daniel.heath/Projects/rea/atlas/.bundle/gems/rubocop-rspec-1.1.0/lib/rubocop/rspec/inject.rb:16:in `defaults!'
/Users/daniel.heath/Projects/rea/atlas/.bundle/gems/rubocop-rspec-1.1.0/lib/rubocop-rspec.rb:9:in `<top (required)>'
/Users/daniel.heath/Projects/rea/atlas/.bundle/gems/rubocop-0.25.0/lib/rubocop/config_loader.rb:43:in `require'

Prefer expect over should

I'm quite surprised this doesn't already exist. Maybe I'm blind. Please let me know if this cop exists already, either in this gem, or core rubocop. I see one here that checks the text for theits, but nothing for the actual code.

Example:

# bad
subject.should eq(2)

# good
expect(subject).to eq(2)

Spec path should end with

spec/models/playlist_item_spec.rb:3:1: C: RSpec/FilePath: Spec path should end with playlist/item*_spec.rb
RSpec.describe Playlist::Item do

RSpec/VerifiedDoubles is overaggressive when nothing stubbed

Note: no tests actually run. May be dumb error in code.

I'm writing a class which is used for plumbing a single value. In the real world, this class takes 4 values, processes 3 of them, and passes one of them through unchanged.

def MyService
  def initialize(opaque_obj)
    @opaque_obj = opaque_obj
  end

  def call
    my_internal_service.new(@opaque_obj).call
  end

  private

  def my_internal_service  # for stubbing
    MyInternalService
  end
end

A spec for this could look something like...

describe 'MyService' do
  let(:opaque_obj) { double(:opaque_obj) }  # uh oh, verified double checker....
  let(:my_internal_service) { class_double('MyInternalService') }
  let(:retval) { true }
  subject { MyService }

  before do
    allow(subject).to_receive(my_internal_service).and_return(my_internal_service) # stub external dependency
  end

  it 'passes var to MyInternalService'
    # assert that input made it to correct spot in output.
    expect(my_internal_service).to receive('new').with(opaque_obj).and_return(retval)

    #and verify that my service passes the retval back
    expect(subject.new(opaque_obj).call).to eq(retval)
  end
end

So we have a case where we want to pass a class through, but treat it as an opaque object, never calling anything on it, modifying it, or even looking at it. From a double perspective, we shouldn't care about being a verifying double or what type it is at all. Keeping a notation in the spec that we're expecting a non-specific class is valuable, but there's no value in verifying it's an instance of a specific class (could be a variety, perhaps unrelated. Go duck typing!)

Proposed fix:

  • if no stubbed methods, expects, or allows applied to the double, let it be! No errors.

Workaround:

  • Use '' (or similar constant) as the value instead. This loses the information that it's really a class typically being passed through. Can also mess with equality checks later if you're fast and loose with reference vs. value equality.

Support for Rubocop 0.40.0

Can we loosen the dependency requirement a bit? Otherwise this will keep being an issue, anytime a new Rubocop release is out.

Change InstanceVariable cop to check for `ivasgn`

While testing Devise controllers we do something like:

@request.env['devise.mapping'] = Devise.mappings[:user]

or

@controller.instance_variable_set :@current_user, user

Then:

RSpec/InstanceVariable: Use let instead of an instance variable

But the variables @request and @controller were not created by me, so a white list would be welcome here. What do you think?

Still maintained?

Is this project still maintained? I would like to use and extend this gem, but first I would like to know if it's still active, or not?

"Use described_class" when not possible

RSpec.describe MyConcern do
  before(:all) do
    Temping.create :temp_model do
      include MyConcern
    end
  end

  # ...
end

Reports this offense:

Use described_class instead of MyConcern

But described_class is not defined inside the block, so I can't use it.

LoadError with Rubocop 0.38.0

I am trying to update from Rubocop 0.37.2 to 0.38.0 and i am getting a LoadError. Not sure if this is an issue on this side or the Rubocop side

$ bundle exec rubocop
Running RuboCop...
rake aborted!
LoadError: cannot load such file -- /Users/username/github/rubocop-rspec
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_loader.rb:40:in `require'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_loader.rb:40:in `block in load_file'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_loader.rb:39:in `each'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_loader.rb:39:in `load_file'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_loader.rb:99:in `configuration_from_file'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_store.rb:41:in `for'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/cli.rb:88:in `apply_default_formatter'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/cli.rb:26:in `run'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/rake_task.rb:49:in `run_cli'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/rake_task.rb:37:in `run_main_task'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/rake_task.rb:29:in `block (2 levels) in initialize'
/Users/username/github/.bundle/ruby/2.2.0/gems/rubocop-0.38.0/lib/rubocop/rake_task.rb:27:in `block in initialize'
Tasks: TOP => default => rubocop
(See full trace by running task with --trace)
$
$ cat .rubocop.yml 
require: rubocop-rspec
$ 

Maybe its the way the rubocop require changed??
rubocop/rubocop@v0.37.2...v0.38.0#diff-e2fc41e8fa0504d203570a8d822495afR40

Metrics

RuboCop has some metrics cops, such as "Metrics/MethodLength" which checks how long methods are. Should RuboCop-rspec have configurable metrics such as "it statements should be no more than 10 lines long", or "it statements should have no more than 5 local variables", or "it statements should have only one expect"?

"Use let instead of an instance variable" in `before(:all)`

Currently when using an instance variable in a before(:all) or an after(:all) call you get the usual:

C: Use let instead of an instance variable

However if you change it over to a let instead of an ivar, RSpec will throw the following warning:

`let` and `subject` declarations are not intended to be called
in an `after(:context)` hook, as they exist to define state that
is reset between each example, while `after(:context)` exists to
cleanup state that is shared across examples in an example group.

I'm inclined to agree with RSpec in this case but I'm looking for feedback, thanks!

Spec path should end with `. . . *_spec.rb` incorrectly being thrown.

Hi,

After looking at some of the source file that throws the spec pathing offense, I think it might be getting thrown by accident for describe blocks for nested classes/modules.

Here's the example code that's causing the error:

require 'spec_helper'

tags = { . . . meta_data . . .}

RSpec.describe Module::PluralizedModelController, tags do
end

Rubocop reports Spec path should end with 'module/pluralized_model_controller*_spec.rb' but the file follows that format. pluralized_model_controller_spec.rb is within a folder named module.

There isn't anything else in the file and the error is repeatable with the example I've given above. Could there be a Regexp issue with https://github.com/nevir/rubocop-rspec/blob/master/lib/rubocop/cop/rspec/file_path.rb?

Thanks!

Name `subject` when referenced explicitly

When referencing subject explicitly is necessary it should be given a name

good

RSpec.describe UserCreator do
  subject(:create) { described_class.new(path) }

  it 'creates a user' do
    expect { create }.to change(User, :count).by(1)
  end
end

bad

RSpec.describe UserCreator do
  subject { described_class.new(path) }

  it 'creates a user' do
    expect { subject }.to change(User, :count).by(1)
  end
end

thoughts? Happy to do a PR

Please bump minor version when adding cops

The 1.5.3 broke my suite because the NamedSubjectCop was introduced. Please use semantic versioning and bump the minor release when you add a new feature (like a new cop). Thank you for all your hard work. This is a really helpful project.

Latest version doesn't work with rubocop 0.34.0

undefined method `red' for #<String:0x00000002d3e468>
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cop/team.rb:101:in `block (2 levels) in process_commissioner_errors'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cop/team.rb:98:in `each'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cop/team.rb:98:in `block in process_commissioner_errors'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cop/team.rb:97:in `each'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cop/team.rb:97:in `process_commissioner_errors'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cop/team.rb:34:in `inspect_file'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:170:in `inspect_file'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:141:in `block in do_inspection_loop'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:135:in `loop'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:135:in `do_inspection_loop'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:87:in `process_file'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:57:in `block in inspect_files'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:55:in `each'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:55:in `inspect_files'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/runner.rb:33:in `run'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/lib/rubocop/cli.rb:26:in `run'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/bin/rubocop:13:in `block in <top (required)>'
/home/ubuntu/xyz-2.1.6/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/gems/rubocop-0.34.0/bin/rubocop:12:in `<top (required)>'
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/bin/rubocop:23:in `load'
             xyz
/home/ubuntu/xyz/vendor/bundle/ruby/2.1.0/bin/rubocop:23:in `<main>' bundle exec rubocop --fail-level E returned exit code 1

Ruby version: '2.1.6'

Maybe rubocop itself broke backwards compatibility (since it's major version is still zero). In this case, we should define a lower bound for rubocop here.

Unify RSpec metadata constants

Many cops have their own ad-hoc definitions of RSpec "test groups" that
include (but are not limited to)

  • it
  • specify
  • xit
  • xspecify
  • fit

These should be pulled up into a set of private constants and tested through
a common set of utility methods (kind of like TopLevelDescribe)

Put `subject` at the top of its context block

When using subject it should be at the top of its context block, ideally separated by one blank line from any lets, befores, or its.

good

RSpec.describe SomeClass do
  subject { described_class.new(foo, bar) }

  let(:foo) { 'foo' }
  let(:bar) { 'bar' }
end

bad

RSpec.describe SomeClass do
  let(:foo) { 'foo' }
  let(:bar) { 'bar' }
  subject { described_class.new(foo, bar) }
end

thoughts? Happy to do a PR

RSpec/DescribeClass should not apply to View specs

Currently, using the standard describe format for View specs:
RSpec.describe "widgets/index" do
we get:
The first argument to describe should be the class or module being tested.

I'm disabling it for now:
RSpec.describe "widgets/index" do # rubocop:disable RSpec/DescribeClass

But the RSpec/DescribeClass cop should probably ignore View specs.

Build is broken?

Travis shows that the build has been broken since "about a month ago". I'm seeing similar failures locally when trying to run the test suite.

Cops should only inspect test files

We have a feature method in our application code that causes rubocop-rspec to complain about using instance variables in our view templates. Seems like maybe some or all of the checks shouldn't be running on application code, only on spec files.

RSpec/FilePath exception with Rubocop 0.36.0

I've just been working through upgrading Rubocop to 0.36.0 and the RSpec/FilePath cop seems to be raising an exception for every file it checks. My rubocop-rspec is version 1.3.1, I believe this is up to date. Info string output by Rubocop at end of debug run:

0.36.0 (using Parser 2.3.0.1, running on ruby 2.2.0 x86_64-darwin14)

The new TargetRubyVersion config has been set to 2.2 (and the app currently runs 2.2.0, as you can see above) and we have no custom configuration for this cop.


This is the full backtrace as given when I run Rubocop with --debug (mildly anonymised)

An error occurred while RSpec/FilePath cop was inspecting /Users/username/src/project_name/spec/models/account/account_spec.rb.
undefined method `const_name' for #<RuboCop::Cop::RSpec::FilePath:0x007faa0206b298>
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-rspec-1.3.1/lib/rubocop/cop/rspec/file_path.rb:25:in `on_top_level_describe'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-rspec-1.3.1/lib/rubocop/rspec/top_level_describe.rb:13:in `on_send'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:38:in `block (2 levels) in on_send'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:88:in `with_cop_error_handling'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:37:in `block in on_send'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:35:in `each'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:35:in `on_send'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:259:in `process'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:276:in `block in process_all'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `map'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `process_all'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/parser-2.3.0.1/lib/parser/ast/processor.rb:9:in `process_regular_node'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:42:in `on_block'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:259:in `process'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:276:in `block in process_all'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `map'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `process_all'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/parser-2.3.0.1/lib/parser/ast/processor.rb:9:in `process_regular_node'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:42:in `on_begin'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/ast-2.2.0/lib/ast/processor/mixin.rb:259:in `process'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/commissioner.rb:54:in `investigate'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cop/team.rb:37:in `inspect_file'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:194:in `inspect_file'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:164:in `block in do_inspection_loop'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:158:in `loop'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:158:in `do_inspection_loop'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:87:in `process_file'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:59:in `block in inspect_files'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:57:in `each'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:57:in `inspect_files'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/runner.rb:35:in `run'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/lib/rubocop/cli.rb:30:in `run'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/bin/rubocop:14:in `block in <top (required)>'
/Users/username/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/gems/rubocop-0.36.0/bin/rubocop:13:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/bin/rubocop:23:in `load'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/bin/rubocop:23:in `<main>'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/bin/ruby_executable_hooks:15:in `eval'
/Users/username/.rvm/gems/ruby-2.2.0@project_name/bin/ruby_executable_hooks:15:in `<main>'

undefined method `call' for Array

bundle exec rubocop spec/models -a
Inspecting 47 files
....

4 files inspected, no offenses detected
undefined method `call' for #<Array:0x007f9603fcc740>
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cop/corrector.rb:46:in `block in rewrite'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cop/corrector.rb:45:in `each'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cop/corrector.rb:45:in `rewrite'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cop/team.rb:90:in `autocorrect_one_cop'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cop/team.rb:65:in `autocorrect'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cop/team.rb:35:in `inspect_file'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:135:in `inspect_file'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:106:in `block in do_inspection_loop'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:100:in `loop'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:100:in `do_inspection_loop'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:78:in `process_file'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:53:in `block in inspect_files'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:51:in `each'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:51:in `inspect_files'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/runner.rb:30:in `run'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/lib/rubocop/cli.rb:26:in `run'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/bin/rubocop:13:in `block in <top (required)>'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.32.1/bin/rubocop:12:in `<top (required)>'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bin/rubocop:23:in `load'
/Users/stereodenis/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bin/rubocop:23:in `<main>'

"Warning: unrecognized cop RSpec/DescribeClass" on running `rubocop`

Some debugging info:

$ cat Gemfile.lock | grep rubocop
    rubocop (0.29.0)
    rubocop-rspec (1.2.1)
  rubocop
  rubocop-rspec
$ cat .rubocop.yml 
require: rubocop-rspec

inherit_from: .rubocop_todo.yml

AllCops:
  RunRailsCops: true
  Exclude:
    - 'bin/**/*'
    - 'vendor/**/*'
    - 'app/controllers/resource_sites_controller.rb'
Documentation:
  Enabled: false
$ cat .rubocop_todo.yml
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-12 16:50:06 -0500 using RuboCop version 0.29.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 16
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
  Enabled: false

# Offense count: 5
Lint/Debugger:
  Enabled: false

# Offense count: 1
# Configuration parameters: AlignWith, SupportedStyles.
Lint/DefEndAlignment:
  Enabled: false

# Offense count: 4
# Configuration parameters: AlignWith, SupportedStyles.
Lint/EndAlignment:
  Enabled: false

# Offense count: 1
Lint/Eval:
  Enabled: false

# Offense count: 1
Lint/HandleExceptions:
  Enabled: false

# Offense count: 2
Lint/ParenthesesAsGroupedExpression:
  Enabled: false

# Offense count: 1
Lint/RescueException:
  Enabled: false

# Offense count: 1
Lint/ShadowingOuterLocalVariable:
  Enabled: false

# Offense count: 1
Lint/UselessAccessModifier:
  Enabled: false

# Offense count: 23
Lint/UselessAssignment:
  Enabled: false

# Offense count: 45
Metrics/AbcSize:
  Max: 87

# Offense count: 9
# Configuration parameters: CountComments.
Metrics/ClassLength:
  Max: 210

# Offense count: 7
Metrics/CyclomaticComplexity:
  Max: 9

# Offense count: 1809
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
  Max: 301

# Offense count: 40
# Configuration parameters: CountComments.
Metrics/MethodLength:
  Max: 97

# Offense count: 1
Metrics/PerceivedComplexity:
  Max: 9

# Offense count: 5
RSpec/DescribeClass:
  Enabled: false

# Offense count: 109
RSpec/DescribedClass:
  Enabled: false

# Offense count: 211
# Configuration parameters: CustomTransform, IgnoredWords.
RSpec/ExampleWording:
  Enabled: false

# Offense count: 2
# Configuration parameters: CustomTransform.
RSpec/FilePath:
  Enabled: false

# Offense count: 15
RSpec/InstanceVariable:
  Enabled: false

# Offense count: 1
RSpec/MultipleDescribes:
  Enabled: false

# Offense count: 10
# Configuration parameters: Include.
Rails/HasAndBelongsToMany:
  Enabled: false

# Offense count: 2
# Configuration parameters: Include.
Rails/Output:
  Enabled: false

# Offense count: 3
# Configuration parameters: Include.
Rails/Validation:
  Enabled: false

# Offense count: 11
Style/AccessorMethodName:
  Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
Style/AlignHash:
  Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AlignParameters:
  Enabled: false

# Offense count: 8
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
Style/CaseIndentation:
  Enabled: false

# Offense count: 13
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
  Enabled: false

# Offense count: 2
Style/EachWithObject:
  Enabled: false

# Offense count: 3
Style/EmptyElse:
  Enabled: false

# Offense count: 7
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
  Enabled: false

# Offense count: 63
# Configuration parameters: MinBodyLength.
Style/GuardClause:
  Enabled: false

# Offense count: 16
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
  Enabled: false

# Offense count: 13
# Cop supports --auto-correct.
Style/Lambda:
  Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Style/LineEndConcatenation:
  Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MultilineOperationIndentation:
  Enabled: false

# Offense count: 2
Style/MultilineTernaryOperator:
  Enabled: false

# Offense count: 4
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
Style/Next:
  Enabled: false

# Offense count: 8
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
  Enabled: false

# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/RaiseArgs:
  Enabled: false

# Offense count: 1
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:
  Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SelfAssignment:
  Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
  Enabled: false

# Offense count: 1
# Configuration parameters: Methods.
Style/SingleLineBlockParams:
  Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Style/SymbolProc:
  Enabled: false

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
Style/TrivialAccessors:
  Enabled: false

# Offense count: 1
Style/UnlessElse:
  Enabled: false

# Offense count: 3
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
  Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: WordRegex.
Style/WordArray:
  MinSize: 5

Looks like the rubocop-rspec cops are successfully being ignored (commenting out the disabling of them causes cop failures), so the warning is very odd.

RSpec/DescribeClass is failing because it is the first rubocop-rspec being encountered. In other words, if I reordered the declarations of rubocop-rspec's cops in the TODO file, the very first rubocop-rspec cop will appear in the warning.

Please let me know if more information is needed!

Cop suggestion: Checks for Gherkin/Cucumber-style scenarios

I've seen a number of teams adopt this style for writing feature specs:
https://about.futurelearn.com/blog/how-we-write-readable-feature-tests-with-rspec/

There's a few things that it would be useful to have checks for:

  • Each line should begin with a valid Gherkin term ('given_', 'when_', 'then_', 'and_' or 'but_')
  • Configurable maximum number of lines per clause (e.g. 3 for a when_) to encourage readability.
  • Presence of at least one 'when_' and one 'then_' per scenario ('given_' can be optional)

undefined method `for_all_cops' error with rubocop `0.39.0`

$ bundle exec rubocop --version
0.39.0
$ 
$ bundle exec rubocop -d
For /Users/user/github_project: configuration from /Users/user/github_project/.rubocop.yml
configuration from /Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-rspec-1.4.0/config/default.yml
undefined method `for_all_cops' for #<Hash:0x007fd33eb71038>
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader.rb:120:in `merge_with_default'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-rspec-1.4.0/lib/rubocop/rspec/inject.rb:17:in `defaults!'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-rspec-1.4.0/lib/rubocop-rspec.rb:9:in `<top (required)>'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader_resolver.rb:16:in `require'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader_resolver.rb:16:in `block in resolve_requires'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader_resolver.rb:12:in `each'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader_resolver.rb:12:in `resolve_requires'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader.rb:39:in `load_file'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_loader.rb:97:in `configuration_from_file'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/config_store.rb:41:in `for'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/cli.rb:88:in `apply_default_formatter'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/lib/rubocop/cli.rb:26:in `run'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/bin/rubocop:14:in `block in <top (required)>'
/usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
/Users/user/github_project/.bundle/ruby/2.2.0/gems/rubocop-0.39.0/bin/rubocop:13:in `<top (required)>'
/Users/user/github_project/.bundle/ruby/2.2.0/bin/rubocop:23:in `load'
/Users/user/github_project/.bundle/ruby/2.2.0/bin/rubocop:23:in `<main>'
Finished in 0.019039359060116112 seconds
$ 

Release 1.5.1

Would you mind releasing the current build on master? I'd like to get rid of this IgnoreSymbolicNames warning

RSpec/VerifiedDoubles requires instance_double in cases where duck typing is employed

Duck typing - double stubs a method, but could be one of many classes with no shared base class

def Runner
  def initialize(worker)
    @worker = worker
  end

  def call
    worker.call
  end
end

A spec for this could look something like...

describe 'Runner' do
  let(:return_val) { 'RetVal' }
  let(:my_worker) { double(:sample_worker, call: return_val) } # ack, verified double checker

  it 'returns the result of my_worker.call'
    expect(Runner.new(my_worker).call).to be(return_val)
  end
end

Proposed fix: ??? unknown here.

Workaround: Define something like this instead in the spec file:

class Spec::ExampleWorker
  def call; end
end

Then change the reference to:

instance_double('Spec::ExampleWorker')

Cannot update RuboCop submodule - "reference is not a tree"

I'm not too familiar with Git submodules, but when I run the command given in the README it fails with:

$ git submodule update --init --depth 1 vendor/rubocop
Submodule 'vendor/rubocop' (https://github.com/bbatsov/rubocop.git) registered for path 'vendor/rubocop'
Cloning into 'vendor/rubocop'...
remote: Counting objects: 830, done.
remote: Compressing objects: 100% (761/761), done.
remote: Total 830 (delta 172), reused 142 (delta 63), pack-reused 0
Receiving objects: 100% (830/830), 1.36 MiB | 366.00 KiB/s, done.
Resolving deltas: 100% (172/172), done.
Checking connectivity... done.
fatal: reference is not a tree: 1473da4b0c81e34548e452d4d3427623bdac16de
Unable to checkout '1473da4b0c81e34548e452d4d3427623bdac16de' in submodule path 'vendor/rubocop'

Cop suggestion: Detect unnecessary usage of `let!`

I often come across code which uses let!(...) for setting up state, but then never makes any direct reference to those identifiers. This setup should be in a before block, or inlined into the example's it block:

Bad

let!(:my_widget) { create(:widget) }

it "..." do
  expect(Widget.count).to eq(1)
end

Good

before { create(:widget) }

it "..." do
  expect(Widget.count).to eq(1)
end

or

it "..." do
  create(:widget)
  expect(Widget.count).to eq(1)
end

Temporarily disable rspec cop?

Is it possible to disable the rspec cop (or specific rules in the rspec cop) as it is with ordinary rubocop rules? For instance:

# rubocop:disable InstanceVariable
@bar
it_behaves_like 'foo', @bar
# rubocop:enable InstanceVariable

@bar could be a long array or something similar that I do not want to declare in the function call to 'foo'.

Refactor cops to use `def_node_matcher`

Looks like it is public API enough. From gitter:

John Backus @backus 11:44

@bbatsov or @alexdowad are you guys happy with def_node_matcher? I'm taking over as maintainer for rubocop-rspec and I'm interested in refactoring some of the cops to use def_node_matcher. Curious if it is considered semipublic api that rubocop extensions can reasonably use

Alex Dowad @alexdowad 13:21

@backus I'm happy with it, don't know what others think.

John Backus @backus 13:25

Cool
If you haven't heard plans to replace it that is good enough for my first question
Other question is basically "would you do a minor version bump if you changed the public API for it?"

Alex Dowad @alexdowad 13:33

@bbatsov chooses when to release new versions and what to call them. I believe he would do a minor version bump when changing the AST-pattern-matching API, if he knew that people were relying on it.

rspec feature spec has no described_class

If a feature or request spec is in the features directory will not have a described_class:

describe "a simple feature" do
end

The response is

The first argument to describe should be the class or module being tested.

Could we turn off this check for feature specs pls?

RSpec/FileName has the wrong namespace

I got this message when running rubocop

/path/to/blog/.rubocop.yml: RSpec/FileName has the wrong namespace - should be Style

What seems to be wrong in my config file?

Documentation:
  Enabled: false
require: rubocop-rspec
AllCops:
  RunRailsCops: true

DescribeMethod and DSL methods

We're trying to figure out the best way to handle DSL methods that are being tested, such as rails associations. Right now we have spec/models/user/associations_spec.rb for grouping those, and a similar validations_spec.rb and whatnot. Any advice on how to structure these so that they can work with the DescribeMethod cop? Right now I'm thinking maybe we just make a spec/models/user/dsl folder and ignore that for the rule or something...

Contexts without any tests

In the following code, I accidentally created a context without any tests, because the it 'is chunky' is after the context has ended.

describe Bacon do
  let(:bacon) { Bacon.new(chunkiness) }
  let(:chunkiness) { false }
  context 'extra chunky' do
    let(:chunkiness) { true }
  end

  it 'is chunky' do
    expect(bacon.chunky?).to be_truthy
  end
end

Contexts without any tests should generate an offense.

Release a new version

I see that there are bugs in v1.3.0 that have since been fixed in master, namely how #autocorrect no longer appends to @corrections. Could you release a new version of rubocop-rspec with this fix?

Prefer verifying doubles over double()

rspec 3.0 added verifying doubles - they raise an exception if you try to stub a method that doesn't exist on the original class.

The documentation is here, and the general rule is to prefer instance_double, class_double and object_double over double().

It'd be great to have a rubocop check that forces me to always use the verifying forms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.