Skip to content

Instantly share code, notes, and snippets.

@johncip johncip/rubocop-rspec.txt
Last active May 6, 2017

Embed
What would you like to do?
## Formatting
* describe_class - argument to 1st `describe` should be a constant
* describe_method - 2nd argument to 1st `describe` should be a method name
* describe_symbol - don't describe a symbol
* described_class - use `described_class` over restating class name
* empty_example_group - no empty example groups
* empty_line_after_final_let - empty line after last `let`
* empty_line_after_subject - empty line after last `subject`
* example_wording - do not use "should" or "it"
* expect_actual - do not expect(5).to eq(a_thing)
* file_path - spec file name should match the thing described
* hook_argument - use only one of `before`, `before(:each)`, or `before(:example)`
* implicit_expect - { is_expected.to } vs. { should }
* leading_subject - `subject` should come before `let`
* let_setup - `let!` blocks must be referenced in an example (use `before` otherwise)
* multiple_describes - only one describe for a given class in a given file
* named_subject - don't do `expect(subject)` -- name the subject
* not_to_not - enforce `to_not` or `not_to`
* repeated_description - examples in a group should not have the same description
* scattered_let - `let`s should be grouped together
* scattered_setup - merge multiple `before` blocks into one
* shared_context - don't confuse `shared_context` and `shared_exmaples`
* single_argument_message_chain - don't use `receive_message_chain` if `receive` will do
## Features
* any_instance - don't use allow_any_instance_of
* before_after_all - don't use `before(:all)` (happens outside of transactions; leaks state)
* focus - don't use focus
* instance_variable - don't use ivars, or don't assign to ivars during an example
* message_chain - don't use `receive_message_chain`
* verified_doubles - don't use `double` (use `instance_double`)
## Metrics
* example_length - set max example length
* multiple_expectations - set max number of `expect` calls in an example
* nested_groups - set max nesting
## Misc
* around_block - "around" blocks should contain test.call
* be_eql - use be over eql (does not include eq)
* instance_spy - if you call `have_received`, use `instance_spy` over `instance_double`
* it_behaves_like - `it_should_behave_like` is bad
* iterated_expectation - use `all` matcher over putting an expectation in a loop
* message_expectation - use only one of `allow` or `expect` with `received`
* message_spies - use only one of `allow` or `expect` with `have_received`
* overwriting_setup - a `let` should not redefine an existing one at the same level
* repeated_example - examples in a group should not have the same implementation
* subject_stub - don't stub the test subject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.