Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve RSpec/AggregateExamples cop #170

Merged
merged 1 commit into from Feb 9, 2020

Commits on Feb 9, 2020

  1. Rework AggregateExamples cop

    The "one expectation per example" rule has been relaxed and allows for several expectations to be set in the same example.
    https://github.com/rubocop-hq/rspec-style-guide#expectations-per-example
    
    In cases the examples don't have any setup, metadata, or even a docstring, and may be aggregated into one thus saving on sometimes expensive context setup.
    
    The cop still does report the cases when the examples might be aggregated.
    
    Block expectation syntax is deliberately not supported due to:
     - `subject { -> { ... } }` syntax being hard to detect
     - aggregation should use composition with `.and`
     - aggregation of the `not_to` is barely possible when a matcher doesn't
     provide a negated variant
     - aggregation of block syntax with non-block syntax should be in a
     specific order
    
    Known caveats:
    The usages if `its` that are testing private methods/readers will result in spec failure. Test only public interface!
    
    Matchers with side effects might affects following expectations when aggregated.
    
    Originally submitted as rubocop/rubocop-rspec#726
    pirj committed Feb 9, 2020
    Copy the full SHA
    1a7a34e View commit details
    Browse the repository at this point in the history