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,389 @@
1
+ # rspec-core [![Build Status](https://github.com/rspec/rspec-core/workflows/RSpec%20CI/badge.svg)](https://github.com/rspec/rspec-core/actions) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.svg)](https://codeclimate.com/github/rspec/rspec-core)
2
+
3
+ rspec-core provides the structure for writing executable examples of how your
4
+ code should behave, and an `rspec` command with tools to constrain which
5
+ examples get run and tailor the output.
6
+
7
+ ## Install
8
+
9
+ gem install rspec # for rspec-core, rspec-expectations, rspec-mocks
10
+ gem install rspec-core # for rspec-core only
11
+ rspec --help
12
+
13
+ Want to run against the `main` branch? You'll need to include the dependent
14
+ RSpec repos as well. Add the following to your `Gemfile`:
15
+
16
+ ```ruby
17
+ %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
18
+ gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'main'
19
+ end
20
+ ```
21
+
22
+ ## Basic Structure
23
+
24
+ RSpec uses the words "describe" and "it" so we can express concepts like a conversation:
25
+
26
+ "Describe an order."
27
+ "It sums the prices of its line items."
28
+
29
+ ```ruby
30
+ RSpec.describe Order do
31
+ it "sums the prices of its line items" do
32
+ order = Order.new
33
+
34
+ order.add_entry(LineItem.new(:item => Item.new(
35
+ :price => Money.new(1.11, :USD)
36
+ )))
37
+ order.add_entry(LineItem.new(:item => Item.new(
38
+ :price => Money.new(2.22, :USD),
39
+ :quantity => 2
40
+ )))
41
+
42
+ expect(order.total).to eq(Money.new(5.55, :USD))
43
+ end
44
+ end
45
+ ```
46
+
47
+ The `describe` method creates an [ExampleGroup](http://rubydoc.info/gems/rspec-core/RSpec/Core/ExampleGroup). Within the
48
+ block passed to `describe` you can declare examples using the `it` method.
49
+
50
+ Under the hood, an example group is a class in which the block passed to
51
+ `describe` is evaluated. The blocks passed to `it` are evaluated in the
52
+ context of an _instance_ of that class.
53
+
54
+ ## Nested Groups
55
+
56
+ You can also declare nested groups using the `describe` or `context`
57
+ methods:
58
+
59
+ ```ruby
60
+ RSpec.describe Order do
61
+ context "with no items" do
62
+ it "behaves one way" do
63
+ # ...
64
+ end
65
+ end
66
+
67
+ context "with one item" do
68
+ it "behaves another way" do
69
+ # ...
70
+ end
71
+ end
72
+ end
73
+ ```
74
+
75
+ Nested groups are subclasses of the outer example group class, providing
76
+ the inheritance semantics you'd want for free.
77
+
78
+ ## Aliases
79
+
80
+ You can declare example groups using either `describe` or `context`.
81
+ For a top level example group, `describe` and `context` are available
82
+ off of `RSpec`. For backwards compatibility, they are also available
83
+ off of the `main` object and `Module` unless you disable monkey
84
+ patching.
85
+
86
+ You can declare examples within a group using any of `it`, `specify`, or
87
+ `example`.
88
+
89
+ ## Shared Examples and Contexts
90
+
91
+ Declare a shared example group using `shared_examples`, and then include it
92
+ in any group using `include_examples`.
93
+
94
+ ```ruby
95
+ RSpec.shared_examples "collections" do |collection_class|
96
+ it "is empty when first created" do
97
+ expect(collection_class.new).to be_empty
98
+ end
99
+ end
100
+
101
+ RSpec.describe Array do
102
+ include_examples "collections", Array
103
+ end
104
+
105
+ RSpec.describe Hash do
106
+ include_examples "collections", Hash
107
+ end
108
+ ```
109
+
110
+ Nearly anything that can be declared within an example group can be declared
111
+ within a shared example group. This includes `before`, `after`, and `around`
112
+ hooks, `let` declarations, and nested groups/contexts.
113
+
114
+ You can also use the names `shared_context` and `include_context`. These are
115
+ pretty much the same as `shared_examples` and `include_examples`, providing
116
+ more accurate naming when you share hooks, `let` declarations, helper methods,
117
+ etc, but no examples.
118
+
119
+ If you want to reuse shared examples or contexts across your RSpec suite you can
120
+ define them in a stand alone _*.rb_ files (_spec/support/shared_examples/definition.rb_
121
+ for example). But you will have to manually `require` them (there is no autoloading of
122
+ _spec/support/_ directory unless you set it up yourself).
123
+
124
+ ## Metadata
125
+
126
+ rspec-core stores a metadata hash with every example and group, which
127
+ contains their descriptions, the locations at which they were
128
+ declared, etc, etc. This hash powers many of rspec-core's features,
129
+ including output formatters (which access descriptions and locations),
130
+ and filtering before and after hooks.
131
+
132
+ Although you probably won't ever need this unless you are writing an
133
+ extension, you can access it from an example like this:
134
+
135
+ ```ruby
136
+ it "does something" do |example|
137
+ expect(example.metadata[:description]).to eq("does something")
138
+ end
139
+ ```
140
+
141
+ ### `described_class`
142
+
143
+ When a class is passed to `describe`, you can access it from an example
144
+ using the `described_class` method, which is a wrapper for
145
+ `example.metadata[:described_class]`.
146
+
147
+ ```ruby
148
+ RSpec.describe Widget do
149
+ example do
150
+ expect(described_class).to equal(Widget)
151
+ end
152
+ end
153
+ ```
154
+
155
+ This is useful in extensions or shared example groups in which the specific
156
+ class is unknown. Taking the collections shared example group from above, we can
157
+ clean it up a bit using `described_class`:
158
+
159
+ ```ruby
160
+ RSpec.shared_examples "collections" do
161
+ it "is empty when first created" do
162
+ expect(described_class.new).to be_empty
163
+ end
164
+ end
165
+
166
+ RSpec.describe Array do
167
+ include_examples "collections"
168
+ end
169
+
170
+ RSpec.describe Hash do
171
+ include_examples "collections"
172
+ end
173
+ ```
174
+
175
+ ## A Word on Scope
176
+
177
+ RSpec has two scopes:
178
+
179
+ * **Example Group**: Example groups are defined by a `describe` or
180
+ `context` block, which is eagerly evaluated when the spec file is
181
+ loaded. The block is evaluated in the context of a subclass of
182
+ `RSpec::Core::ExampleGroup`, or a subclass of the parent example group
183
+ when you're nesting them.
184
+ * **Example**: Examples -- typically defined by an `it` block -- and any other
185
+ blocks with per-example semantics -- such as a `before(:example)` hook -- are
186
+ evaluated in the context of
187
+ an _instance_ of the example group class to which the example belongs.
188
+ Examples are _not_ executed when the spec file is loaded; instead,
189
+ RSpec waits to run any examples until all spec files have been loaded,
190
+ at which point it can apply filtering, randomization, etc.
191
+
192
+ To make this more concrete, consider this code snippet:
193
+
194
+ ``` ruby
195
+ RSpec.describe "Using an array as a stack" do
196
+ def build_stack
197
+ []
198
+ end
199
+
200
+ before(:example) do
201
+ @stack = build_stack
202
+ end
203
+
204
+ it 'is initially empty' do
205
+ expect(@stack).to be_empty
206
+ end
207
+
208
+ context "after an item has been pushed" do
209
+ before(:example) do
210
+ @stack.push :item
211
+ end
212
+
213
+ it 'allows the pushed item to be popped' do
214
+ expect(@stack.pop).to eq(:item)
215
+ end
216
+ end
217
+ end
218
+ ```
219
+
220
+ Under the covers, this is (roughly) equivalent to:
221
+
222
+ ``` ruby
223
+ class UsingAnArrayAsAStack < RSpec::Core::ExampleGroup
224
+ def build_stack
225
+ []
226
+ end
227
+
228
+ def before_example_1
229
+ @stack = build_stack
230
+ end
231
+
232
+ def it_is_initially_empty
233
+ expect(@stack).to be_empty
234
+ end
235
+
236
+ class AfterAnItemHasBeenPushed < self
237
+ def before_example_2
238
+ @stack.push :item
239
+ end
240
+
241
+ def it_allows_the_pushed_item_to_be_popped
242
+ expect(@stack.pop).to eq(:item)
243
+ end
244
+ end
245
+ end
246
+ ```
247
+
248
+ To run these examples, RSpec would (roughly) do the following:
249
+
250
+ ``` ruby
251
+ example_1 = UsingAnArrayAsAStack.new
252
+ example_1.before_example_1
253
+ example_1.it_is_initially_empty
254
+
255
+ example_2 = UsingAnArrayAsAStack::AfterAnItemHasBeenPushed.new
256
+ example_2.before_example_1
257
+ example_2.before_example_2
258
+ example_2.it_allows_the_pushed_item_to_be_popped
259
+ ```
260
+
261
+ ## The `rspec` Command
262
+
263
+ When you install the rspec-core gem, it installs the `rspec` executable,
264
+ which you'll use to run rspec. The `rspec` command comes with many useful
265
+ options.
266
+ Run `rspec --help` to see the complete list.
267
+
268
+ ## Store Command Line Options `.rspec`
269
+
270
+ You can store command line options in a `.rspec` file in the project's root
271
+ directory, and the `rspec` command will read them as though you typed them on
272
+ the command line.
273
+
274
+ ## Get Started
275
+
276
+ Start with a simple example of behavior you expect from your system. Do
277
+ this before you write any implementation code:
278
+
279
+ ```ruby
280
+ # in spec/calculator_spec.rb
281
+ RSpec.describe Calculator do
282
+ describe '#add' do
283
+ it 'returns the sum of its arguments' do
284
+ expect(Calculator.new.add(1, 2)).to eq(3)
285
+ end
286
+ end
287
+ end
288
+ ```
289
+
290
+ Run this with the rspec command, and watch it fail:
291
+
292
+ ```
293
+ $ rspec spec/calculator_spec.rb
294
+ ./spec/calculator_spec.rb:1: uninitialized constant Calculator
295
+ ```
296
+
297
+ Address the failure by defining a skeleton of the `Calculator` class:
298
+
299
+ ```ruby
300
+ # in lib/calculator.rb
301
+ class Calculator
302
+ def add(a, b)
303
+ end
304
+ end
305
+ ```
306
+
307
+ Be sure to require the implementation file in the spec:
308
+
309
+ ```ruby
310
+ # in spec/calculator_spec.rb
311
+ # - RSpec adds ./lib to the $LOAD_PATH
312
+ require "calculator"
313
+ ```
314
+
315
+ Now run the spec again, and watch the expectation fail:
316
+
317
+ ```
318
+ $ rspec spec/calculator_spec.rb
319
+ F
320
+
321
+ Failures:
322
+
323
+ 1) Calculator#add returns the sum of its arguments
324
+ Failure/Error: expect(Calculator.new.add(1, 2)).to eq(3)
325
+
326
+ expected: 3
327
+ got: nil
328
+
329
+ (compared using ==)
330
+ # ./spec/calculator_spec.rb:6:in `block (3 levels) in <top (required)>'
331
+
332
+ Finished in 0.00131 seconds (files took 0.10968 seconds to load)
333
+ 1 example, 1 failure
334
+
335
+ Failed examples:
336
+
337
+ rspec ./spec/calculator_spec.rb:5 # Calculator#add returns the sum of its arguments
338
+ ```
339
+
340
+ Implement the simplest solution, by changing the definition of `Calculator#add` to:
341
+
342
+ ```ruby
343
+ def add(a, b)
344
+ a + b
345
+ end
346
+ ```
347
+
348
+ Now run the spec again, and watch it pass:
349
+
350
+ ```
351
+ $ rspec spec/calculator_spec.rb
352
+ .
353
+
354
+ Finished in 0.000315 seconds
355
+ 1 example, 0 failures
356
+ ```
357
+
358
+ Use the `documentation` formatter to see the resulting spec:
359
+
360
+ ```
361
+ $ rspec spec/calculator_spec.rb --format doc
362
+ Calculator
363
+ #add
364
+ returns the sum of its arguments
365
+
366
+ Finished in 0.000379 seconds
367
+ 1 example, 0 failures
368
+ ```
369
+
370
+ ## Contributing
371
+
372
+ Once you've set up the environment, you'll need to cd into the working
373
+ directory of whichever repo you want to work in. From there you can run the
374
+ specs and cucumber features, and make patches.
375
+
376
+ NOTE: You do not need to use rspec-dev to work on a specific RSpec repo. You
377
+ can treat each RSpec repo as an independent project.
378
+
379
+ * [Build details](BUILD_DETAIL.md)
380
+ * [Code of Conduct](CODE_OF_CONDUCT.md)
381
+ * [Detailed contributing guide](CONTRIBUTING.md)
382
+ * [Development setup guide](DEVELOPMENT.md)
383
+
384
+ ## Also see
385
+
386
+ * [https://github.com/rspec/rspec](https://github.com/rspec/rspec)
387
+ * [https://github.com/rspec/rspec-expectations](https://github.com/rspec/rspec-expectations)
388
+ * [https://github.com/rspec/rspec-mocks](https://github.com/rspec/rspec-mocks)
389
+ * [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.