Skip to content

Commit 71aa65f

Browse files
committed
Remove RSpec guideline for one-liners
Previously one-liners could be written in RSpec like: it { should validate_presence_of(:name) } In RSpec 3, the `should` syntax was removed because it monkey-patched `Object`. The one-liner syntax shown above was kept because its `should` did not monkey-patch `Object`. To avoid confusion, RSpec 3 added an `expect`-style way of writing one-liners: it { is_expected.to validate_presence_of(:name) } According to Myron Marston: > Some users have expressed confusion about how this should relates to the > expect syntax and if you can continue using it. It will continue to be > available in RSpec 3 (again, regardless of your syntax configuration), but > we’ve also added an alternate API that is a bit more consistent with the > expect syntax From: [New API for one-liners](http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new_api_for_oneliners_) A proposal was made to switch to using the new `is_expected.to` syntaxin [this pull request](#215). However, responses were mixed. Given the lack of consensus one way or the other, let's remove the guideline entirely and let each project decide which syntax to use.
1 parent 3a7b7fd commit 71aa65f

File tree

2 files changed

+0
-3
lines changed

2 files changed

+0
-3
lines changed

style/testing/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ Testing
88
* Separate setup, exercise, verification, and teardown phases with newlines.
99
* Use RSpec's [`expect` syntax].
1010
* Use RSpec's [`allow` syntax] for method stubs.
11-
* Use `should` shorthand for [one-liners with an implicit subject].
1211
* Use `not_to` instead of `to_not` in RSpec expectations.
1312
* Prefer the `have_css` matcher to the `have_selector` matcher in Capybara assertions.
1413

1514
[`expect` syntax]: http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
1615
[`allow` syntax]: https://github.com/rspec/rspec-mocks#method-stubs
17-
[one-liners with an implicit subject]: https://github.com/rspec/rspec-expectations/blob/master/Should.md#one-liners
1816
[predicate-example]: predicate_tests_spec.rb
1917

2018
Acceptance Tests

style/testing/unit_test_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
describe SomeClass do
2-
32
context "when defining a subject" do
43
# GOOD
54
# it's okay to define a `subject` here:

0 commit comments

Comments
 (0)