Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab0af51

Browse files
authored
Merge pull request rubocop#588 from sauloperez/doc-non-goals
Add non-goals section documenting should vs expect
2 parents 1a6af99 + 6b15075 commit ab0af51

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

.github/CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ do so.
1010
* Check that the issue has not already been reported.
1111
* Check that the issue has not already been fixed in the latest code
1212
(a.k.a. `master`).
13+
* Check if the issue is a non-goal of RuboCop RSpec.
1314
* Be clear, concise and precise in your description of the problem.
1415
* Open an issue with a descriptive title and a summary in grammatically correct,
1516
complete sentences.

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,46 @@ RSpec/FilePath:
9898
- spec/my_poorly_named_spec_file.rb
9999
```
100100

101+
## Non-goals of RuboCop RSpec
102+
103+
### Enforcing `should` vs. `expect` syntax
104+
105+
Enforcing
106+
107+
```ruby
108+
expect(calculator.compute(line_item)).to eq(5)
109+
```
110+
111+
over
112+
113+
```ruby
114+
calculator.compute(line_item).should == 5
115+
```
116+
117+
is a feature of RSpec itself – you can read about it in the [RSpec Documentation](https://relishapp.com/rspec/rspec-expectations/docs/syntax-configuration#disable-should-syntax)
118+
119+
### Enforcing an explicit RSpec receiver for top-level methods (disabling monkey patching)
120+
121+
Enforcing
122+
123+
```ruby
124+
Rspec.describe MyClass do
125+
...
126+
end
127+
```
128+
129+
over
130+
131+
```ruby
132+
describe MyClass do
133+
...
134+
end
135+
```
136+
137+
can be achieved using RSpec's `disable_monkey_patching!` method, which you can read more about in the [RSpec Documentation](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). This will also prevent `should` from being defined on every object in your system.
138+
139+
Before disabling `should` you will need all your specs to use the `expect` syntax. You can use [Transpec](http://yujinakayama.me/transpec/), which will do the conversion for you.
140+
101141

102142
## Contributing
103143

0 commit comments

Comments
 (0)