rails-rfc6570 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +3 -1
  4. data/lib/rails/rfc6570/formatter.rb +9 -12
  5. data/lib/rails/rfc6570/patches.rb +1 -1
  6. data/lib/rails/rfc6570/version.rb +1 -1
  7. data/lib/rails/rfc6570.rb +10 -29
  8. data/spec/dummy/config/application.rb +5 -1
  9. data/spec/dummy/config/environments/test.rb +1 -1
  10. data/spec/rails/rfc6570/extensions/route_set_spec.rb +29 -0
  11. data/spec/rails/rfc6570/helper_spec.rb +44 -0
  12. data/spec/rails/rfc6570/visitor_spec.rb +12 -0
  13. data/spec/rails/rfc6570_spec.rb +49 -1
  14. data/spec/spec_helper.rb +6 -0
  15. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-3bcd2110ca87/LICENSE +21 -0
  16. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-3bcd2110ca87/README.md +23 -0
  17. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-3bcd2110ca87/rubocop-config.gemspec +31 -0
  18. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.3/CHANGELOG.md +285 -0
  19. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.3/MIT-LICENSE +21 -0
  20. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.3/README.rdoc +57 -0
  21. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.3/CHANGELOG.md +129 -0
  22. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.3/MIT-LICENSE +21 -0
  23. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.3/README.rdoc +40 -0
  24. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.3/CHANGELOG.md +309 -0
  25. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.3/MIT-LICENSE +20 -0
  26. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.3/README.rdoc +40 -0
  27. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/CHANGELOG.md +301 -0
  28. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/LICENSE.txt +202 -0
  29. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/README.md +121 -0
  30. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/addressable.gemspec +28 -0
  31. data/vendor/bundle/ruby/3.4.0/gems/base64-0.3.0/README.md +48 -0
  32. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.1/README.md +138 -0
  33. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.1/benchmark.gemspec +32 -0
  34. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.2.3/LICENSE +56 -0
  35. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.2.3/bigdecimal.gemspec +57 -0
  36. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/MIT-LICENSE +20 -0
  37. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/README.md +258 -0
  38. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/builder.gemspec +49 -0
  39. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/CHANGELOG.md +603 -0
  40. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/LICENSE.txt +21 -0
  41. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/README.md +407 -0
  42. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.4/LICENSE +20 -0
  43. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.4/README.md +188 -0
  44. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.4/connection_pool.gemspec +24 -0
  45. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/LICENSE +18 -0
  46. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/README.md +192 -0
  47. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/crass.gemspec +31 -0
  48. data/vendor/bundle/ruby/3.4.0/gems/diff-lcs-1.6.2/CHANGELOG.md +518 -0
  49. data/vendor/bundle/ruby/3.4.0/gems/diff-lcs-1.6.2/README.md +92 -0
  50. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.3/LICENSE.txt +22 -0
  51. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.3/drb.gemspec +42 -0
  52. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  53. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/MIT-LICENSE +21 -0
  54. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/README.rdoc +151 -0
  55. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/MIT-LICENSE +20 -0
  56. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/README.md +127 -0
  57. data/vendor/bundle/ruby/3.4.0/gems/logger-1.7.0/README.md +104 -0
  58. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.1/CHANGELOG.md +598 -0
  59. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.1/MIT-LICENSE.txt +23 -0
  60. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.1/README.md +410 -0
  61. data/vendor/bundle/ruby/3.4.0/gems/minitest-5.25.5/README.rdoc +842 -0
  62. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.10-x86_64-linux-gnu/LICENSE-DEPENDENCIES.md +2224 -0
  63. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.10-x86_64-linux-gnu/LICENSE.md +9 -0
  64. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.10-x86_64-linux-gnu/README.md +293 -0
  65. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/CHANGELOG.md +498 -0
  66. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/LICENSE.txt +22 -0
  67. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.2/README.md +222 -0
  68. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/README.ja.rdoc +58 -0
  69. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/README.rdoc +60 -0
  70. data/vendor/bundle/ruby/3.4.0/gems/rack-3.2.1/CHANGELOG.md +1236 -0
  71. data/vendor/bundle/ruby/3.4.0/gems/rack-3.2.1/MIT-LICENSE +20 -0
  72. data/vendor/bundle/ruby/3.4.0/gems/rack-3.2.1/README.md +376 -0
  73. data/vendor/bundle/ruby/3.4.0/gems/rack-test-2.2.0/MIT-LICENSE.txt +20 -0
  74. data/vendor/bundle/ruby/3.4.0/gems/rack-test-2.2.0/README.md +139 -0
  75. data/vendor/bundle/ruby/3.4.0/gems/rails-dom-testing-2.3.0/MIT-LICENSE +23 -0
  76. data/vendor/bundle/ruby/3.4.0/gems/rails-dom-testing-2.3.0/README.md +94 -0
  77. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/CHANGELOG.md +255 -0
  78. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/MIT-LICENSE +23 -0
  79. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/README.md +267 -0
  80. data/vendor/bundle/ruby/3.4.0/gems/rake-13.3.0/MIT-LICENSE +21 -0
  81. data/vendor/bundle/ruby/3.4.0/gems/rake-13.3.0/README.rdoc +155 -0
  82. data/vendor/bundle/ruby/3.4.0/gems/rake-13.3.0/rake.gemspec +101 -0
  83. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/LICENSE +21 -0
  84. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/README.md +107 -0
  85. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/rake-release.gemspec +23 -0
  86. data/vendor/bundle/ruby/3.4.0/gems/rspec-3.13.1/LICENSE.md +27 -0
  87. data/vendor/bundle/ruby/3.4.0/gems/rspec-3.13.1/README.md +47 -0
  88. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.5/LICENSE.md +26 -0
  89. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.5/README.md +389 -0
  90. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.5/LICENSE.md +25 -0
  91. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.5/README.md +326 -0
  92. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.5/LICENSE.md +25 -0
  93. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.5/README.md +465 -0
  94. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.6/LICENSE.md +23 -0
  95. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.6/README.md +40 -0
  96. data/vendor/bundle/ruby/3.4.0/gems/securerandom-0.4.1/README.md +72 -0
  97. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/LICENSE +19 -0
  98. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/README.md +406 -0
  99. data/vendor/bundle/ruby/3.4.0/gems/uri-1.0.3/README.md +55 -0
  100. data/vendor/bundle/ruby/3.4.0/gems/useragent-0.16.11/LICENSE +20 -0
  101. data/vendor/bundle/ruby/3.4.0/gems/useragent-0.16.11/README.md +42 -0
  102. data/vendor/bundle/ruby/3.4.0/specifications/actionpack-8.0.3.gemspec +36 -0
  103. data/vendor/bundle/ruby/3.4.0/specifications/actionview-8.0.3.gemspec +33 -0
  104. data/vendor/bundle/ruby/3.4.0/specifications/activesupport-8.0.3.gemspec +38 -0
  105. data/vendor/bundle/ruby/3.4.0/specifications/addressable-2.8.7.gemspec +30 -0
  106. data/vendor/bundle/ruby/3.4.0/specifications/base64-0.3.0.gemspec +23 -0
  107. data/vendor/bundle/ruby/3.4.0/specifications/benchmark-0.4.1.gemspec +23 -0
  108. data/vendor/bundle/ruby/3.4.0/specifications/bigdecimal-3.2.3.gemspec +25 -0
  109. data/vendor/bundle/ruby/3.4.0/specifications/builder-3.3.0.gemspec +22 -0
  110. data/vendor/bundle/ruby/3.4.0/specifications/concurrent-ruby-1.3.5.gemspec +24 -0
  111. data/vendor/bundle/ruby/3.4.0/specifications/connection_pool-2.5.4.gemspec +28 -0
  112. data/vendor/bundle/ruby/3.4.0/specifications/crass-1.0.6.gemspec +27 -0
  113. data/vendor/bundle/ruby/3.4.0/specifications/diff-lcs-1.6.2.gemspec +35 -0
  114. data/vendor/bundle/ruby/3.4.0/specifications/drb-2.2.3.gemspec +22 -0
  115. data/vendor/bundle/ruby/3.4.0/specifications/erubi-1.13.1.gemspec +29 -0
  116. data/vendor/bundle/ruby/3.4.0/specifications/i18n-1.14.7.gemspec +26 -0
  117. data/vendor/bundle/ruby/3.4.0/specifications/logger-1.7.0.gemspec +22 -0
  118. data/vendor/bundle/ruby/3.4.0/specifications/loofah-2.24.1.gemspec +27 -0
  119. data/vendor/bundle/ruby/3.4.0/specifications/minitest-5.25.5.gemspec +31 -0
  120. data/vendor/bundle/ruby/3.4.0/specifications/nokogiri-1.18.10-x86_64-linux-gnu.gemspec +31 -0
  121. data/vendor/bundle/ruby/3.4.0/specifications/public_suffix-6.0.2.gemspec +24 -0
  122. data/vendor/bundle/ruby/3.4.0/specifications/racc-1.8.1.gemspec +28 -0
  123. data/vendor/bundle/ruby/3.4.0/specifications/rack-3.2.1.gemspec +31 -0
  124. data/vendor/bundle/ruby/3.4.0/specifications/rack-session-2.1.1.gemspec +30 -0
  125. data/vendor/bundle/ruby/3.4.0/specifications/rack-test-2.2.0.gemspec +29 -0
  126. data/vendor/bundle/ruby/3.4.0/specifications/rails-dom-testing-2.3.0.gemspec +28 -0
  127. data/vendor/bundle/ruby/3.4.0/specifications/rails-html-sanitizer-1.6.2.gemspec +27 -0
  128. data/vendor/bundle/ruby/3.4.0/specifications/rake-13.3.0.gemspec +26 -0
  129. data/vendor/bundle/ruby/3.4.0/specifications/rake-release-1.3.0.gemspec +26 -0
  130. data/vendor/bundle/ruby/3.4.0/specifications/rspec-3.13.1.gemspec +31 -0
  131. data/vendor/bundle/ruby/3.4.0/specifications/rspec-core-3.13.5.gemspec +31 -0
  132. data/vendor/bundle/ruby/3.4.0/specifications/rspec-expectations-3.13.5.gemspec +29 -0
  133. data/vendor/bundle/ruby/3.4.0/specifications/rspec-mocks-3.13.5.gemspec +29 -0
  134. data/vendor/bundle/ruby/3.4.0/specifications/rspec-support-3.13.6.gemspec +29 -0
  135. data/vendor/bundle/ruby/3.4.0/specifications/securerandom-0.4.1.gemspec +23 -0
  136. data/vendor/bundle/ruby/3.4.0/specifications/tzinfo-2.0.6.gemspec +30 -0
  137. data/vendor/bundle/ruby/3.4.0/specifications/uri-1.0.3.gemspec +23 -0
  138. data/vendor/bundle/ruby/3.4.0/specifications/useragent-0.16.11.gemspec +25 -0
  139. metadata +129 -8
  140. data/spec/dummy/log/test.log +0 -432
@@ -0,0 +1,326 @@
1
+ # RSpec Expectations [![Build Status](https://github.com/rspec/rspec-expectations/workflows/RSpec%20CI/badge.svg)](https://github.com/rspec/rspec-expectations/actions) [![Code Climate](https://codeclimate.com/github/rspec/rspec-expectations.svg)](https://codeclimate.com/github/rspec/rspec-expectations)
2
+
3
+ RSpec::Expectations lets you express expected outcomes on an object in an
4
+ example.
5
+
6
+ ```ruby
7
+ expect(account.balance).to eq(Money.new(37.42, :USD))
8
+ ```
9
+
10
+ ## Install
11
+
12
+ If you want to use rspec-expectations with rspec, just install the rspec gem
13
+ and RubyGems will also install rspec-expectations for you (along with
14
+ rspec-core and rspec-mocks):
15
+
16
+ ```shell
17
+ gem install rspec
18
+ ```
19
+
20
+ Want to run against the `main` branch? You'll need to include the dependent
21
+ RSpec repos as well. Add the following to your `Gemfile`:
22
+
23
+ ```ruby
24
+ %w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
25
+ gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'main'
26
+ end
27
+ ```
28
+
29
+ If you want to use rspec-expectations with another tool, like Test::Unit,
30
+ Minitest, or Cucumber, you can install it directly:
31
+
32
+ ```shell
33
+ gem install rspec-expectations
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ Once you've set up the environment, you'll need to cd into the working
39
+ directory of whichever repo you want to work in. From there you can run the
40
+ specs and cucumber features, and make patches.
41
+
42
+ NOTE: You do not need to use rspec-dev to work on a specific RSpec repo. You
43
+ can treat each RSpec repo as an independent project.
44
+
45
+ - [Build details](BUILD_DETAIL.md)
46
+ - [Code of Conduct](CODE_OF_CONDUCT.md)
47
+ - [Detailed contributing guide](CONTRIBUTING.md)
48
+ - [Development setup guide](DEVELOPMENT.md)
49
+
50
+ ## Basic usage
51
+
52
+ Here's an example using rspec-core:
53
+
54
+ ```ruby
55
+ RSpec.describe Order do
56
+ it "sums the prices of the items in its line items" do
57
+ order = Order.new
58
+ order.add_entry(LineItem.new(:item => Item.new(
59
+ :price => Money.new(1.11, :USD)
60
+ )))
61
+ order.add_entry(LineItem.new(:item => Item.new(
62
+ :price => Money.new(2.22, :USD),
63
+ :quantity => 2
64
+ )))
65
+ expect(order.total).to eq(Money.new(5.55, :USD))
66
+ end
67
+ end
68
+ ```
69
+
70
+ The `describe` and `it` methods come from rspec-core. The `Order`, `LineItem`, `Item` and `Money` classes would be from _your_ code. The last line of the example
71
+ expresses an expected outcome. If `order.total == Money.new(5.55, :USD)`, then
72
+ the example passes. If not, it fails with a message like:
73
+
74
+ ```
75
+ expected: #<Money @value=5.55 @currency=:USD>
76
+ got: #<Money @value=1.11 @currency=:USD>
77
+ ```
78
+
79
+ ## Built-in matchers
80
+
81
+ ### Equivalence
82
+
83
+ ```ruby
84
+ expect(actual).to eq(expected) # passes if actual == expected
85
+ expect(actual).to eql(expected) # passes if actual.eql?(expected)
86
+ expect(actual).not_to eql(not_expected) # passes if not(actual.eql?(expected))
87
+ ```
88
+
89
+ Note: The new `expect` syntax no longer supports the `==` matcher.
90
+
91
+ ### Identity
92
+
93
+ ```ruby
94
+ expect(actual).to be(expected) # passes if actual.equal?(expected)
95
+ expect(actual).to equal(expected) # passes if actual.equal?(expected)
96
+ ```
97
+
98
+ ### Comparisons
99
+
100
+ ```ruby
101
+ expect(actual).to be > expected
102
+ expect(actual).to be >= expected
103
+ expect(actual).to be <= expected
104
+ expect(actual).to be < expected
105
+ expect(actual).to be_within(delta).of(expected)
106
+ ```
107
+
108
+ ### Regular expressions
109
+
110
+ ```ruby
111
+ expect(actual).to match(/expression/)
112
+ ```
113
+
114
+ Note: The new `expect` syntax no longer supports the `=~` matcher.
115
+
116
+ ### Types/classes
117
+
118
+ ```ruby
119
+ expect(actual).to be_an_instance_of(expected) # passes if actual.class == expected
120
+ expect(actual).to be_a(expected) # passes if actual.kind_of?(expected)
121
+ expect(actual).to be_an(expected) # an alias for be_a
122
+ expect(actual).to be_a_kind_of(expected) # another alias
123
+ ```
124
+
125
+ ### Truthiness
126
+
127
+ ```ruby
128
+ expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
129
+ expect(actual).to be true # passes if actual == true
130
+ expect(actual).to be_falsy # passes if actual is falsy (nil or false)
131
+ expect(actual).to be false # passes if actual == false
132
+ expect(actual).to be_nil # passes if actual is nil
133
+ expect(actual).to_not be_nil # passes if actual is not nil
134
+ ```
135
+
136
+ ### Expecting errors
137
+
138
+ ```ruby
139
+ expect { ... }.to raise_error
140
+ expect { ... }.to raise_error(ErrorClass)
141
+ expect { ... }.to raise_error("message")
142
+ expect { ... }.to raise_error(ErrorClass, "message")
143
+ ```
144
+
145
+ ### Expecting throws
146
+
147
+ ```ruby
148
+ expect { ... }.to throw_symbol
149
+ expect { ... }.to throw_symbol(:symbol)
150
+ expect { ... }.to throw_symbol(:symbol, 'value')
151
+ ```
152
+
153
+ ### Yielding
154
+
155
+ ```ruby
156
+ expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args
157
+
158
+ expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded
159
+
160
+ expect { |b| 5.tap(&b) }.to yield_with_args(5)
161
+ expect { |b| 5.tap(&b) }.to yield_with_args(Integer)
162
+ expect { |b| "a string".tap(&b) }.to yield_with_args(/str/)
163
+
164
+ expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
165
+ expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
166
+ ```
167
+
168
+ ### Predicate matchers
169
+
170
+ ```ruby
171
+ expect(actual).to be_xxx # passes if actual.xxx?
172
+ expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
173
+ ```
174
+
175
+ ### Ranges (Ruby >= 1.9 only)
176
+
177
+ ```ruby
178
+ expect(1..10).to cover(3)
179
+ ```
180
+
181
+ ### Collection membership
182
+
183
+ ```ruby
184
+ # exact order, entire collection
185
+ expect(actual).to eq(expected)
186
+
187
+ # exact order, partial collection (based on an exact position)
188
+ expect(actual).to start_with(expected)
189
+ expect(actual).to end_with(expected)
190
+
191
+ # any order, entire collection
192
+ expect(actual).to match_array(expected)
193
+
194
+ # You can also express this by passing the expected elements
195
+ # as individual arguments
196
+ expect(actual).to contain_exactly(expected_element1, expected_element2)
197
+
198
+ # any order, partial collection
199
+ expect(actual).to include(expected)
200
+ ```
201
+
202
+ #### Examples
203
+
204
+ ```ruby
205
+ expect([1, 2, 3]).to eq([1, 2, 3]) # Order dependent equality check
206
+ expect([1, 2, 3]).to include(1) # Exact ordering, partial collection matches
207
+ expect([1, 2, 3]).to include(2, 3) #
208
+ expect([1, 2, 3]).to start_with(1) # As above, but from the start of the collection
209
+ expect([1, 2, 3]).to start_with(1, 2) #
210
+ expect([1, 2, 3]).to end_with(3) # As above but from the end of the collection
211
+ expect([1, 2, 3]).to end_with(2, 3) #
212
+ expect({:a => 'b'}).to include(:a => 'b') # Matching within hashes
213
+ expect("this string").to include("is str") # Matching within strings
214
+ expect("this string").to start_with("this") #
215
+ expect("this string").to end_with("ring") #
216
+ expect([1, 2, 3]).to contain_exactly(2, 3, 1) # Order independent matches
217
+ expect([1, 2, 3]).to match_array([3, 2, 1]) #
218
+
219
+ # Order dependent compound matchers
220
+ expect(
221
+ [{:a => 'hash'},{:a => 'another'}]
222
+ ).to match([a_hash_including(:a => 'hash'), a_hash_including(:a => 'another')])
223
+ ```
224
+
225
+ ## `should` syntax
226
+
227
+ In addition to the `expect` syntax, rspec-expectations continues to support the
228
+ `should` syntax:
229
+
230
+ ```ruby
231
+ actual.should eq expected
232
+ actual.should be > 3
233
+ [1, 2, 3].should_not include 4
234
+ ```
235
+
236
+ See [detailed information on the `should` syntax and its usage.](https://github.com/rspec/rspec-expectations/blob/main/Should.md)
237
+
238
+ ## Compound Matcher Expressions
239
+
240
+ You can also create compound matcher expressions using `and` or `or`:
241
+
242
+ ``` ruby
243
+ expect(alphabet).to start_with("a").and end_with("z")
244
+ expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
245
+ ```
246
+
247
+ ## Composing Matchers
248
+
249
+ Many of the built-in matchers are designed to take matchers as
250
+ arguments, to allow you to flexibly specify only the essential
251
+ aspects of an object or data structure. In addition, all of the
252
+ built-in matchers have one or more aliases that provide better
253
+ phrasing for when they are used as arguments to another matcher.
254
+
255
+ ### Examples
256
+
257
+ ```ruby
258
+ expect { k += 1.05 }.to change { k }.by( a_value_within(0.1).of(1.0) )
259
+
260
+ expect { s = "barn" }.to change { s }
261
+ .from( a_string_matching(/foo/) )
262
+ .to( a_string_matching(/bar/) )
263
+
264
+ expect(["barn", 2.45]).to contain_exactly(
265
+ a_value_within(0.1).of(2.5),
266
+ a_string_starting_with("bar")
267
+ )
268
+
269
+ expect(["barn", "food", 2.45]).to end_with(
270
+ a_string_matching("foo"),
271
+ a_value > 2
272
+ )
273
+
274
+ expect(["barn", 2.45]).to include( a_string_starting_with("bar") )
275
+
276
+ expect(:a => "food", :b => "good").to include(:a => a_string_matching(/foo/))
277
+
278
+ hash = {
279
+ :a => {
280
+ :b => ["foo", 5],
281
+ :c => { :d => 2.05 }
282
+ }
283
+ }
284
+
285
+ expect(hash).to match(
286
+ :a => {
287
+ :b => a_collection_containing_exactly(
288
+ a_string_starting_with("f"),
289
+ an_instance_of(Integer)
290
+ ),
291
+ :c => { :d => (a_value < 3) }
292
+ }
293
+ )
294
+
295
+ expect { |probe|
296
+ [1, 2, 3].each(&probe)
297
+ }.to yield_successive_args( a_value < 2, 2, a_value > 2 )
298
+ ```
299
+
300
+ ## Usage outside rspec-core
301
+
302
+ You always need to load `rspec/expectations` even if you only want to use one part of the library:
303
+
304
+ ```ruby
305
+ require 'rspec/expectations'
306
+ ```
307
+
308
+ Then simply include `RSpec::Matchers` in any class:
309
+
310
+ ```ruby
311
+ class MyClass
312
+ include RSpec::Matchers
313
+
314
+ def do_something(arg)
315
+ expect(arg).to be > 0
316
+ # do other stuff
317
+ end
318
+ end
319
+ ```
320
+
321
+ ## Also see
322
+
323
+ * [https://github.com/rspec/rspec](https://github.com/rspec/rspec)
324
+ * [https://github.com/rspec/rspec-core](https://github.com/rspec/rspec-core)
325
+ * [https://github.com/rspec/rspec-mocks](https://github.com/rspec/rspec-mocks)
326
+ * [https://github.com/rspec/rspec-rails](https://github.com/rspec/rspec-rails)
@@ -0,0 +1,25 @@
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ * Copyright © 2012 David Chelimsky, Myron Marston
5
+ * Copyright © 2006 David Chelimsky, The RSpec Development Team
6
+ * Copyright © 2005 Steven Baker
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ "Software"), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.