File: index.adoc

package info (click to toggle)
ruby-rubocop-rspec 2.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,892 kB
  • sloc: ruby: 22,283; makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,922 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
= RuboCop RSpec

RSpec-specific analysis for your projects, as an extension to
https://github.com/rubocop/rubocop[RuboCop].

RuboCop RSpec follows the https://docs.rubocop.org/rubocop/versioning.html[RuboCop versioning guide].
In a nutshell, between major versions new cops are introduced in a special `pending` status.
That means that they won’t be run unless explicitly told otherwise.
RuboCop will warn on start that certain cops are neither explicitly enabled and disabled.
On a major version release, all `pending` cops are enabled.

== Project Goals

* Enforce the guidelines and best practices outlined in the community https://rspec.rubystyle.guide[RSpec style guide]
* Simplify the process of adopting new RSpec functionality

== Non-goals of RuboCop RSpec

=== Enforcing `should` vs. `expect` syntax

Enforcing

[source,ruby]
----
expect(calculator.compute(line_item)).to eq(5)
----

over

[source,ruby]
----
calculator.compute(line_item).should == 5
----

is a feature of RSpec itself – you can read about it in the https://relishapp.com/rspec/rspec-expectations/docs/syntax-configuration#disable-should-syntax[RSpec Documentation].

=== Enforcing an explicit RSpec receiver for top-level methods (disabling monkey patching)

Enforcing

[source,ruby]
----
RSpec.describe MyClass do
  ...
end
----

over

[source,ruby]
----
describe MyClass do
  ...
end
----

can be achieved using RSpec's `disable_monkey_patching!` method, which you can read more about in the https://relishapp.com/rspec/rspec-core/v/3-7/docs/configuration/zero-monkey-patching-mode#monkey-patched-methods-are-undefined-with-%60disable-monkey-patching!%60[RSpec Documentation]. This will also prevent `should` from being defined on every object in your system.

Before disabling `should` you will need all your specs to use the `expect` syntax. You can use http://yujinakayama.me/transpec/[Transpec], which will do the conversion for you.