rspec-sleeping_king_studios 2.5.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '096c6d91e990581772d795cedab4356ac8b07f84712d2a52e61fd715d47bfbc2'
4
- data.tar.gz: b2f7d0d162e1678be6a8ed0886ec1a9670321bbe64abc6a4f58a30b58e479725
3
+ metadata.gz: 54fafe35b632818612bf767e1a2ad05e9338fd4dd68a7356f4540473423c9888
4
+ data.tar.gz: 6cfa48a9b350c0b19ac7fdd6a1d6a14a274b0a26ef873842b84d5e9d82438062
5
5
  SHA512:
6
- metadata.gz: c6bd478d39bd8ec15b23b12440ca82b839e652376cfb761b2fa56c1e6228c6ebfd0658156bc886c5ab58a31547801dc581e732be98392280f913beb240ee4b49
7
- data.tar.gz: ccc88ee28086629ab456961cdc746a8647c0c285d1d0e1734000abae8ece56532324f36e9568a64e00156186e4c5c0eeab1912f5029b7315ad717e855170447b
6
+ metadata.gz: f342e4dc730b32e64339aaac823350f8de678ec8d3820c9f64ea6a8037e29df4fc0d91e6e02cc8d13a8e0b1368003907c749a3801f64060a2669519933bd2b52
7
+ data.tar.gz: 0f4f12cb9d5c1e350363759f2672bb9e96876f570b1bcc3aa4068171b47fcb6a752b51a9d8ca6ce184e172b3f9a1de0ef1b5bcc4e2cbbb80b6ccdef7f5761438
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.7.0
4
+
5
+ ### Concerns
6
+
7
+ Implemented RSpec::SleepingKingStudios::Contract and the IncludeContract concern. These provide a mechanism for documenting and sharing specifications between projects.
8
+
9
+ ### Matchers
10
+
11
+ Renamed the `#alias_method` matcher to `#have_aliased_method`, and renamed the AliasMethodMatcher to HaveAliasedMethodMatcher. Using the older matcher will trigger a deprecation warning.
12
+
13
+ ## 2.6.0
14
+
15
+ Deprecated the DelegateMethod matcher. Use `rspec-mocks` expectations instead.
16
+
17
+ Deprecated the Include matcher with a block. Use the `satisfy` matcher instead.
18
+
19
+ ### Matchers
20
+
21
+ Updated RespondToMatcher to check the arity of `#initialize` when matching against a class and the method name is `:new`.
22
+
3
23
  ## 2.5.1
4
24
 
5
25
  Fixed a compatibility issue with Rails 6 configuration objects.
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ merlin@sleepingkingstudios.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
126
+ at [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/DEVELOPMENT.md CHANGED
@@ -1,26 +1,9 @@
1
1
  # Development Notes
2
2
 
3
- ## Version 2.6
4
-
5
- ### Features - Matchers
6
-
7
- - RespondToMatcher: |
8
- update to match core respond_to matcher
9
- - uses the signature from initialize to validate checks for new
10
- - see https://github.com/rspec/rspec-expectations/blob/master/Changelog.md
11
- subclass BeConstructibleMatcher from RespondTo ?
12
-
13
- ## Version 2.6+
14
-
15
- - DeepMatcher: |
16
- - indifferent - symbol/string keys
17
- - ordered - pre-sort arrays?
18
- - only homogenous arrays?
19
- - odd results unless equality comparison
20
-
21
3
  ## Version 3.0
22
4
 
23
5
  - Extract out Rails-specific matchers to RSpec::SleepingKingStudios::Rails.
6
+ - Drop Rails 3 support.
24
7
  - Refactor property, constant matchers to Define$1Matcher.
25
8
  - HaveConstantMatcher, HaveReaderMatcher, HavePredicateMatcher, HavePropertyMatcher, HaveWriterMatcher.
26
9
  - Designate define_* macros as primary, have_* as aliases.
@@ -31,6 +14,12 @@
31
14
 
32
15
  ## Future Tasks
33
16
 
17
+ - DeepMatcher: |
18
+ - indifferent - symbol/string keys
19
+ - ordered - pre-sort arrays?
20
+ - only homogenous arrays?
21
+ - odd results unless equality comparison
22
+
34
23
  ### Bug Fixes
35
24
 
36
25
  - false negative on #alias_method?
data/README.md CHANGED
@@ -2,31 +2,38 @@
2
2
 
3
3
  A collection of matchers and extensions to ease TDD/BDD using RSpec. Extends built-in matchers with new functionality, such as support for Ruby 2.0+ keyword arguments, and adds new matchers for testing boolean-ness, object reader/writer properties, object constructor arguments, ActiveModel validations, and more. Also defines shared example groups for more expressive testing.
4
4
 
5
- ## Support
5
+ ## About
6
6
 
7
- RSpec::SleepingKingStudios is tested against RSpec 3.3 through 3.7.
7
+ ### Compatibility
8
8
 
9
- Currently, the following versions of Ruby are officially supported:
9
+ RSpec::SleepingKingStudios is tested against the following dependencies:
10
10
 
11
- * 2.4
12
- * 2.5
13
- * 2.6
11
+ - Ruby (MRI) 2.7 through 3.1
12
+ - RSpec versions 3.4 through 3.10
13
+ - ActiveModel versions 3.0 through 6.1
14
14
 
15
- For Ruby 2.0 support, use version 2.1 or earlier: `gem "rspec-sleeping_king_studios", "~> 2.1.1"`.
15
+ ### Documentation
16
16
 
17
- For RSpec 3.0 to 3.2 support, use version 2.2 or earlier: `gem "rspec-sleeping_king_studios", "~> 2.2.2"`.
17
+ Documentation is generated using [YARD](https://yardoc.org/), and can be generated locally using the `yard` gem.
18
18
 
19
- If you require a previous version of Ruby or RSpec, the 1.0 branch supports Ruby 1.9.3 and RSpec 2: `gem "rspec-sleeping_king_studios", "~> 1.0.1"`. However, changes from 2.0 and higher will not be backported.
19
+ ### License
20
20
 
21
- ## Contribute
21
+ Copyright (c) 2013-2021 Rob Smith
22
22
 
23
- ### GitHub
23
+ RSpec::SleepingKingStudios is released under the [MIT License](https://opensource.org/licenses/MIT).
24
+
25
+ ### Contribute
24
26
 
25
27
  The canonical repository for this gem is located at https://github.com/sleepingkingstudios/rspec-sleeping_king_studios.
26
28
 
27
- ### A Note From The Developer
29
+ To report a bug or submit a feature request, please use the [Issue Tracker](https://github.com/sleepingkingstudios/rspec-sleeping_king_studios/issues).
30
+
31
+ To contribute code, please fork the repository, make the desired updates, and then provide a [Pull Request](https://github.com/sleepingkingstudios/rspec-sleeping_king_studios/pulls). Pull requests must include appropriate tests for consideration, and all code must be properly formatted.
32
+
33
+ ### Code of Conduct
34
+
35
+ Please note that the `RSpec::SleepingKingStudios` project is released with a [Contributor Code of Conduct](https://github.com/sleepingkingstudios/rspec-sleeping_king_studios/blob/master/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
28
36
 
29
- Hi, I'm Rob Smith, a Ruby Engineer and the developer of this library. I use these tools every day, but they're not just written for me. If you find this project helpful in your own work, or if you have any questions, suggestions or critiques, please feel free to get in touch! I can be reached on GitHub (see above, and feel encouraged to submit bug reports or merge requests there) or via email at `merlin@sleepingkingstudios.com`. I look forward to hearing from you!
30
37
 
31
38
  ## Configuration
32
39
 
@@ -149,6 +156,113 @@ Sets the value of the named constant to the specified value within the context o
149
156
 
150
157
  Creates a new class with the specified base class and sets the value of the named constant to the created class within the context of the current example.
151
158
 
159
+ <a id="include-contract"></a>
160
+
161
+ ### Include Contract
162
+
163
+ ```ruby
164
+ require 'rspec/sleepingkingstudios/concerns/include_contract'
165
+ ```
166
+
167
+ Defines helpers for including reusable contracts in RSpec example groups.
168
+
169
+ Contracts are a mechanism for sharing tests between projects. For example, one library may define an interface or specification for a type of object, while a second library implements that object. By defining a contract and sharing that contract as part of the library, the developer ensures that any object that matches the contract has correctly implemented and conforms to the interface. This reduces duplication of tests and provides resiliency as an interface is developed over time and across versions of the library.
170
+
171
+ Mechanically speaking, each contract encapsulates a section of RSpec code. When the contract is included in a spec, that code is then injected into the spec. Writing a contract, therefore, is no different than writing any other RSpec specification - it is only the delivery mechanism that differs. A contract can be any object that responds to #to_proc; the simplest contract is therefore a Proc or lambda that contains some RSpec code.
172
+
173
+ Although the examples use bare `lambda`s, any object that responds to `#to_proc` can be used as a contract. See also [Contracts](#contracts), which provide an approach to defining contracts that makes documenting contracts much cleaner.
174
+
175
+ ```ruby
176
+ module ExampleContracts
177
+ # This contract asserts that the object has the Enumerable module as an
178
+ # ancestor, and that it responds to the #each method.
179
+ SHOULD_BE_ENUMERABLE_CONTRACT = lambda do
180
+ it 'should be Enumerable' do
181
+ expect(subject).to be_a Enumerable
182
+ end
183
+
184
+ it 'should respond to #each' do
185
+ expect(subject).to respond_to(:each).with(0).arguments
186
+ end
187
+ end
188
+ end
189
+
190
+ RSpec.describe Array do
191
+ extend RSpec::SleepingKingStudios::Concerns::IncludeContract
192
+
193
+ include_contract ExampleContracts::SHOULD_BE_ENUMERABLE_CONTRACT
194
+ end
195
+
196
+ RSpec.describe Hash do
197
+ extend RSpec::SleepingKingStudios::Concerns::IncludeContract
198
+ include ExampleContracts
199
+
200
+ include_contract 'should be enumerable'
201
+ end
202
+ ```
203
+
204
+ We can also write contracts that take parameters, allowing us to customize the expected behavior of the object.
205
+
206
+ ```ruby
207
+ module SerializerContracts
208
+ # This contract asserts that the serialized result has the expected values.
209
+ SHOULD_SERIALIZE_ATTRIBUTES_CONTRACT = lambda \
210
+ do |*attributes, **values, &block|
211
+ describe '#serialize' do
212
+ let(:serialized) { subject.serialize }
213
+
214
+ it { expect(subject).to respond_to(:serialize).with(0).arguments }
215
+
216
+ attributes.each do |attribute|
217
+ it "should serialize #{attribute}" do
218
+ expect(serialized[attribute]).to be == subject[attribute]
219
+ end
220
+ end
221
+
222
+ values.each do |attribute, value|
223
+ it "should serialize #{attribute}" do
224
+ expect(serialized[attribute]).to be == value
225
+ end
226
+ end
227
+
228
+ instance_exec(&block) if block
229
+ end
230
+ end
231
+ end
232
+
233
+ RSpec.describe CaptainPicard do
234
+ extend RSpec::SleepingKingStudios::Concerns::IncludeContract
235
+ include SerializerContracts
236
+
237
+ include_contract 'should serialize attributes',
238
+ :name,
239
+ :rank,
240
+ lights: 4 do
241
+ it 'should serialize the catchphrase' do
242
+ expect(serialized[:catchphrase]).to be == 'Make it so.'
243
+ end
244
+ end
245
+ end
246
+ ```
247
+
248
+ First, we pass the contract a series of attribute names. These are used to assert that the serialized attributes match the values on the original object.
249
+
250
+ Second, we pass the contract a set of attribute names and values. These are used to assert that the serialized attributes have the specified values.
251
+
252
+ Finally, we can pass the contract a block, which the contract then executes. Note that the block is executed in the context of our describe block, and thus can take advantage of our memoized #serialized helper method.
253
+
254
+ #### `.include_contract`
255
+
256
+ The `.include_contract` class method applies the contract to the current example group. It passes any additional arguments, keywords, or block to the contract implementation.
257
+
258
+ #### `.finclude_contract`
259
+
260
+ The `.finclude_contract` class method creates a new focused context inside the current example group and applies the contract to that context. If RSpec is configured to run only focused specs, then only the contract specs will be run. This is useful to quickly focus and run the specs from a particular contract.
261
+
262
+ #### `.xinclude_contract`
263
+
264
+ The `.xinclude_contract` class method creates a new skipped context inside the current example group and applies the contract to that context. The contract specs will not be run, but will instead be marked as pending. This is useful to temporarily disable the specs from a particular contract.
265
+
152
266
  ### Focus Examples
153
267
 
154
268
  require 'rspec/sleeping_king_studios/concerns/focus_examples'
@@ -322,7 +436,154 @@ A simplified syntax for re-using shared context or examples without having to ex
322
436
 
323
437
  (also `::xwrap_context`) A shortcut for wrapping the context or examples in an automatically-skipped `describe` block, similar to the built-in `xit` and `xdescribe` methods.
324
438
 
325
- ## Custom Matchers
439
+ ## Contracts
440
+
441
+ ```ruby
442
+ require 'rspec/sleepingkingstudios/contract'
443
+ ```
444
+
445
+ An `RSpec::SleepingKingStudios::Contract` object encapsulates a partial RSpec specification. Unlike a traditional shared example group, a contract can be reused across projects, allowing a library to define an interface, provide a reference implementation, and publish tests that validate other implementations.
446
+
447
+ Contracts can be added to an example group either through the `.apply` method or using the [Include Contract concern](#include-contract).
448
+
449
+ ```ruby
450
+ module ExampleContracts
451
+ # This contract asserts that the object has the Enumerable module as an
452
+ # ancestor, and that it responds to the #each method.
453
+ class ShouldBeEnumerableContract < RSpec::SleepingKingStudios::Contract
454
+ # @!method apply(example_group)
455
+ # Adds the contract to the example group.
456
+
457
+ contract do
458
+ it 'should be Enumerable' do
459
+ expect(subject).to be_a Enumerable
460
+ end
461
+
462
+ it 'should respond to #each' do
463
+ expect(subject).to respond_to(:each).with(0).arguments
464
+ end
465
+ end
466
+ end
467
+ end
468
+
469
+ RSpec.describe Array do
470
+ ExampleContracts::SHOULD_BE_ENUMERABLE_CONTRACT.apply(self)
471
+ end
472
+
473
+ RSpec.describe Hash do
474
+ extend RSpec::SleepingKingStudios::Concerns::IncludeContract
475
+ include ExampleContracts
476
+
477
+ include_contract 'should be enumerable'
478
+ end
479
+ ```
480
+
481
+ The major advantage a Contract object provides over using a Proc is documentation - tools such as YARD do not gracefully handle bare lambdas, while the functionality and requirements of a Contract can be specified using standard patterns, such as documenting the parameters passed to a contract using the #apply method.
482
+
483
+ Contracts can be defined with parameters, which allows us to customize the expected behavior of the object.
484
+
485
+ ```ruby
486
+ module SerializerContracts
487
+ # This contract asserts that the serialized result has the expected
488
+ # values.
489
+ #
490
+ # First, we pass the contract a series of attribute names. These are
491
+ # used to assert that the serialized attributes match the values on the
492
+ # original object.
493
+ #
494
+ # Second, we pass the contract a set of attribute names and values.
495
+ # These are used to assert that the serialized attributes have the
496
+ # specified values.
497
+ #
498
+ # Finally, we can pass the contract a block, which the contract then
499
+ # executes. Note that the block is executed in the context of our
500
+ # describe block, and thus can take advantage of our memoized
501
+ # #serialized helper method.
502
+ class ShouldSerializeAttributesContract
503
+ extend RSpec::SleepingKingStudios::Contract
504
+
505
+ contract do |*attributes, **values, &block|
506
+ describe '#serialize' do
507
+ let(:serialized) { subject.serialize }
508
+
509
+ it { expect(subject).to respond_to(:serialize).with(0).arguments }
510
+
511
+ attributes.each do |attribute|
512
+ it "should serialize #{attribute}" do
513
+ expect(serialized[attribute]).to be == subject[attribute]
514
+ end
515
+ end
516
+
517
+ values.each do |attribute, value|
518
+ it "should serialize #{attribute}" do
519
+ expect(serialized[attribute]).to be == value
520
+ end
521
+ end
522
+
523
+ instance_exec(&block) if block
524
+ end
525
+ end
526
+ end
527
+
528
+ RSpec.describe CaptainPicard do
529
+ SerializerContracts::ShouldSerializeAttributesContract.apply(
530
+ self,
531
+ :name,
532
+ :rank,
533
+ lights: 4) \
534
+ do
535
+ it 'should serialize the catchphrase' do
536
+ expect(serialized[:catchphrase]).to be == 'Make it so.'
537
+ end
538
+ end
539
+ end
540
+ ```
541
+
542
+ ### Contract Methods
543
+
544
+ Each `RSpec::SleepingKingStudios::Contract` defines the following methods.
545
+
546
+ #### `.apply`
547
+
548
+ The `.apply` method adds the contract to the given example group, using the same internals used in the [Include Contract concern](#include-contract).
549
+
550
+ ```ruby
551
+ RSpec.describe Book do
552
+ subject(:book) { Book.first }
553
+
554
+ SerializerContracts::ShouldSerializeAttributesContract.apply(
555
+ self,
556
+ :title,
557
+ author: book.author.as_json
558
+ )
559
+ end
560
+ ```
561
+
562
+ #### `.contract`
563
+
564
+ The `.contract` method is used to define the contract implementation.
565
+
566
+ ```ruby
567
+ module ModelContracts
568
+ class ShouldHavePrimaryKey
569
+ extend RSpec::SleepingKingStudios::Contract
570
+
571
+ contract do |primary_key_name: :id|
572
+ describe "##{primary_key_name}" do
573
+ it { expect(subject).to respond_to(primary_key_name).with(0).arguments }
574
+ end
575
+ end
576
+ end
577
+ end
578
+ ```
579
+
580
+ If a block is not given, it returns the current implementation as a `Proc` (or `nil`, if a contract implementation has not yet been set).
581
+
582
+ #### `.to_proc`
583
+
584
+ The `.to_proc` method returns the current implementation as a `Proc` (or `nil`, if a contract implementation has not yet been set).
585
+
586
+ ## Matchers
326
587
 
327
588
  To enable a custom matcher, simply require the associated file. Matchers can be required individually or by category:
328
589
 
@@ -431,22 +692,6 @@ Now has additional chaining functionality to validate the number of arguments ac
431
692
 
432
693
  These matchers check core functionality, such as object boolean-ness, the existence of properties, and so on.
433
694
 
434
- #### `#alias_method` Matcher
435
-
436
- require 'rspec/sleeping_king_studios/matchers/core/alias_method'
437
-
438
- Checks if the object aliases the specified method with the specified other name. Matches if and only if the object responds to both the old and new method names, and if the old method and the new method are the same method.
439
-
440
- **How To Use**:
441
-
442
- expect(object).to alias_method(:old_method).as(:new_method)
443
-
444
- **Parameters:** Old method name. Expects the name of the method which has been aliased as a String or Symbol.
445
-
446
- **Chaining:**
447
-
448
- * **`#as`:** Required. Expects one String or Symbol, which is the name of the generated method.
449
-
450
695
  #### `#be_a_uuid` Matcher
451
696
 
452
697
  require 'rspec/sleeping_king_studios/matchers/core/be_a_uuid'
@@ -550,34 +795,21 @@ When the value does not match the expectation, the failure message will provide
550
795
  # + :errors => got ["Insufficient funds"]
551
796
  # ~ :status => expected 200, got 400
552
797
 
553
- #### `#delegate_method` Matcher
554
-
555
- require 'rspec/sleeping_king_studios/matchers/core/delegate_method'
798
+ #### `#have_aliased_method` Matcher
556
799
 
557
- Checks if the actual object forwards the specified method to the specified target. Can also specify that arguments, keywords, and/or a block are passed to the target, and that the object returns the specified values.
800
+ require 'rspec/sleeping_king_studios/matchers/core/have_aliased_method'
558
801
 
559
- **How To Use:**
560
-
561
- expect(object).to delegate_method(:my_method).to(target)
802
+ Checks if the object aliases the specified method with the specified other name. Matches if and only if the object responds to both the old and new method names, and if the old method and the new method are the same method.
562
803
 
563
- # Specify that arguments must be passed to the target.
564
- expect(object).to delegate_method(:my_method).to(target).with_arguments(:ichi, :ni, :san)
565
- expect(object).to delegate_method(:my_method).to(target).with_keywords(:foo => 'foo', :bar => 'bar')
566
- expect(object).to delegate_method(:my_method).to(target).with_a_block
804
+ **How To Use**:
567
805
 
568
- # Specify that the method must return the specified value.
569
- expect(object).to delegate_method(:my_method).to(target).and_return(true) # Called 1 time.
570
- expect(object).to delegate_method(:my_method).to(target).and_return(0, 1, 2) # Called 3 times.
806
+ expect(object).to have_aliased_method(:old_method).as(:new_method)
571
807
 
572
- **Parameters:** Method name. Expects a string or symbol that is a valid identifier.
808
+ **Parameters:** Old method name. Expects the name of the method which has been aliased as a String or Symbol.
573
809
 
574
810
  **Chaining:**
575
811
 
576
- * **`#to`:** Required. Expects an object, which is the target the method should be forwarded to.
577
- * **`#with_arguments`:** (also `and_arguments`) Expects one or more arguments. Specifies that when the method is called on the actual object with the given arguments, those arguments are then passed on to the target object when the method is called on the target.
578
- * **`#with_keywords:`** (also `and_keywords`) Expects a hash of keywords and values. Specifies that when the method is called on the actual object with the given keywords, those keywords are then passed on to the target object when the method is called on the target.
579
- * **`#with_a_block:`** (also `and_a_block`) Specifies that when the method is called on the actual object a block argument, thhe block is then passed on to the target object when the method is called on the target.
580
- * **`#and_return`:** Expects one or more arguments. The method is called on the actual object one time for each value passed into `#and_return`. Specifies that the return value of calling the method on the actual object is the corresponding value passed into `#and_return`.
812
+ * **`#as`:** Required. Expects one String or Symbol, which is the name of the generated method.
581
813
 
582
814
  #### `#have_changed` Matcher
583
815
 
@@ -1,5 +1,6 @@
1
1
  # lib/rspec/sleeping_king_studios/all.rb
2
2
 
3
3
  require 'rspec/sleeping_king_studios/concerns/all'
4
+ require 'rspec/sleeping_king_studios/contract'
4
5
  require 'rspec/sleeping_king_studios/examples/all'
5
6
  require 'rspec/sleeping_king_studios/matchers/all'