rspec-core 2.99.0 → 3.0.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 (216) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +1 -0
  4. data/Changelog.md +339 -1
  5. data/License.txt +1 -0
  6. data/README.md +19 -37
  7. data/exe/rspec +2 -23
  8. data/lib/rspec/core/backport_random.rb +336 -0
  9. data/lib/rspec/core/backtrace_formatter.rb +70 -0
  10. data/lib/rspec/core/configuration.rb +479 -577
  11. data/lib/rspec/core/configuration_options.rb +71 -54
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +86 -18
  14. data/lib/rspec/core/example.rb +267 -119
  15. data/lib/rspec/core/example_group.rb +381 -393
  16. data/lib/rspec/core/filter_manager.rb +133 -114
  17. data/lib/rspec/core/flat_map.rb +18 -0
  18. data/lib/rspec/core/formatters/base_formatter.rb +51 -125
  19. data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
  20. data/lib/rspec/core/formatters/console_codes.rb +24 -1
  21. data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
  22. data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
  23. data/lib/rspec/core/formatters/helpers.rb +14 -36
  24. data/lib/rspec/core/formatters/html_formatter.rb +58 -65
  25. data/lib/rspec/core/formatters/html_printer.rb +12 -18
  26. data/lib/rspec/core/formatters/json_formatter.rb +54 -31
  27. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  28. data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
  29. data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
  30. data/lib/rspec/core/formatters.rb +90 -43
  31. data/lib/rspec/core/hooks.rb +325 -270
  32. data/lib/rspec/core/memoized_helpers.rb +45 -156
  33. data/lib/rspec/core/metadata.rb +284 -236
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
  36. data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
  37. data/lib/rspec/core/mocking_adapters/null.rb +12 -0
  38. data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
  39. data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
  40. data/lib/rspec/core/notifications.rb +511 -0
  41. data/lib/rspec/core/option_parser.rb +49 -74
  42. data/lib/rspec/core/ordering.rb +156 -0
  43. data/lib/rspec/core/pending.rb +94 -96
  44. data/lib/rspec/core/project_initializer/.rspec +3 -0
  45. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
  46. data/lib/rspec/core/project_initializer.rb +24 -64
  47. data/lib/rspec/core/rake_task.rb +44 -130
  48. data/lib/rspec/core/reporter.rb +76 -59
  49. data/lib/rspec/core/ruby_project.rb +2 -1
  50. data/lib/rspec/core/runner.rb +117 -52
  51. data/lib/rspec/core/shared_context.rb +10 -10
  52. data/lib/rspec/core/shared_example_group.rb +108 -121
  53. data/lib/rspec/core/version.rb +3 -1
  54. data/lib/rspec/core/warnings.rb +40 -0
  55. data/lib/rspec/core/world.rb +66 -10
  56. data/lib/rspec/core.rb +64 -104
  57. data.tar.gz.sig +3 -0
  58. metadata +75 -322
  59. metadata.gz.sig +1 -0
  60. data/exe/autospec +0 -13
  61. data/features/Autotest.md +0 -38
  62. data/features/README.md +0 -17
  63. data/features/Upgrade.md +0 -364
  64. data/features/command_line/README.md +0 -28
  65. data/features/command_line/example_name_option.feature +0 -97
  66. data/features/command_line/exit_status.feature +0 -82
  67. data/features/command_line/format_option.feature +0 -75
  68. data/features/command_line/init.feature +0 -18
  69. data/features/command_line/line_number_appended_to_path.feature +0 -140
  70. data/features/command_line/line_number_option.feature +0 -53
  71. data/features/command_line/order.feature +0 -26
  72. data/features/command_line/pattern_option.feature +0 -49
  73. data/features/command_line/rake_task.feature +0 -122
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -22
  76. data/features/command_line/tag.feature +0 -98
  77. data/features/command_line/warnings_option.feature +0 -29
  78. data/features/configuration/alias_example_to.feature +0 -48
  79. data/features/configuration/backtrace_clean_patterns.feature +0 -102
  80. data/features/configuration/custom_settings.feature +0 -84
  81. data/features/configuration/default_path.feature +0 -38
  82. data/features/configuration/deprecation_stream.feature +0 -58
  83. data/features/configuration/fail_fast.feature +0 -77
  84. data/features/configuration/failure_exit_code.feature +0 -36
  85. data/features/configuration/order_and_seed.feature +0 -3
  86. data/features/configuration/output_stream.feature +0 -24
  87. data/features/configuration/pattern.feature +0 -38
  88. data/features/configuration/profile.feature +0 -220
  89. data/features/configuration/read_options_from_file.feature +0 -90
  90. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  91. data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
  92. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  93. data/features/example_groups/basic_structure.feature +0 -55
  94. data/features/example_groups/shared_context.feature +0 -74
  95. data/features/example_groups/shared_examples.feature +0 -294
  96. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
  97. data/features/filtering/exclusion_filters.feature +0 -138
  98. data/features/filtering/if_and_unless.feature +0 -168
  99. data/features/filtering/inclusion_filters.feature +0 -105
  100. data/features/formatters/configurable_colors.feature +0 -31
  101. data/features/formatters/custom_formatter.feature +0 -36
  102. data/features/formatters/json_formatter.feature +0 -30
  103. data/features/formatters/text_formatter.feature +0 -46
  104. data/features/helper_methods/arbitrary_methods.feature +0 -40
  105. data/features/helper_methods/let.feature +0 -50
  106. data/features/helper_methods/modules.feature +0 -149
  107. data/features/hooks/around_hooks.feature +0 -343
  108. data/features/hooks/before_and_after_hooks.feature +0 -427
  109. data/features/hooks/filtering.feature +0 -234
  110. data/features/metadata/current_example.feature +0 -56
  111. data/features/metadata/described_class.feature +0 -17
  112. data/features/metadata/user_defined.feature +0 -113
  113. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  114. data/features/mock_framework_integration/use_flexmock.feature +0 -96
  115. data/features/mock_framework_integration/use_mocha.feature +0 -97
  116. data/features/mock_framework_integration/use_rr.feature +0 -98
  117. data/features/mock_framework_integration/use_rspec.feature +0 -97
  118. data/features/pending/pending_examples.feature +0 -229
  119. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  120. data/features/step_definitions/additional_cli_steps.rb +0 -49
  121. data/features/subject/attribute_of_subject.feature +0 -124
  122. data/features/subject/explicit_subject.feature +0 -101
  123. data/features/subject/implicit_subject.feature +0 -63
  124. data/features/subject/one_liner_syntax.feature +0 -71
  125. data/features/support/env.rb +0 -14
  126. data/features/support/rubinius.rb +0 -6
  127. data/lib/autotest/discover.rb +0 -10
  128. data/lib/autotest/rspec2.rb +0 -77
  129. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  130. data/lib/rspec/core/backward_compatibility.rb +0 -55
  131. data/lib/rspec/core/caller_filter.rb +0 -60
  132. data/lib/rspec/core/command_line.rb +0 -47
  133. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  134. data/lib/rspec/core/deprecation.rb +0 -26
  135. data/lib/rspec/core/drb_command_line.rb +0 -26
  136. data/lib/rspec/core/drb_options.rb +0 -87
  137. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  138. data/lib/rspec/core/extensions/kernel.rb +0 -9
  139. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  140. data/lib/rspec/core/extensions/ordered.rb +0 -27
  141. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  142. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  143. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  144. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  145. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  146. data/lib/rspec/core/mocking/with_rspec.rb +0 -27
  147. data/lib/rspec/core/shared_example_group/collection.rb +0 -45
  148. data/spec/autotest/discover_spec.rb +0 -49
  149. data/spec/autotest/failed_results_re_spec.rb +0 -45
  150. data/spec/autotest/rspec_spec.rb +0 -133
  151. data/spec/command_line/order_spec.rb +0 -204
  152. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  153. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  154. data/spec/rspec/core/command_line_spec.rb +0 -127
  155. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  156. data/spec/rspec/core/configuration_options_spec.rb +0 -417
  157. data/spec/rspec/core/configuration_spec.rb +0 -2072
  158. data/spec/rspec/core/deprecation_spec.rb +0 -27
  159. data/spec/rspec/core/deprecations_spec.rb +0 -59
  160. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  161. data/spec/rspec/core/drb_options_spec.rb +0 -193
  162. data/spec/rspec/core/dsl_spec.rb +0 -25
  163. data/spec/rspec/core/example_group_spec.rb +0 -1337
  164. data/spec/rspec/core/example_spec.rb +0 -502
  165. data/spec/rspec/core/filter_manager_spec.rb +0 -246
  166. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
  167. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
  168. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  169. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
  170. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
  171. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  172. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  173. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
  174. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
  175. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
  176. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  177. data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
  178. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  179. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  180. data/spec/rspec/core/hooks_spec.rb +0 -269
  181. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  182. data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
  183. data/spec/rspec/core/metadata_spec.rb +0 -514
  184. data/spec/rspec/core/option_parser_spec.rb +0 -297
  185. data/spec/rspec/core/pending_example_spec.rb +0 -260
  186. data/spec/rspec/core/pending_spec.rb +0 -27
  187. data/spec/rspec/core/project_initializer_spec.rb +0 -130
  188. data/spec/rspec/core/rake_task_spec.rb +0 -202
  189. data/spec/rspec/core/reporter_spec.rb +0 -167
  190. data/spec/rspec/core/resources/a_bar.rb +0 -0
  191. data/spec/rspec/core/resources/a_foo.rb +0 -0
  192. data/spec/rspec/core/resources/a_spec.rb +0 -1
  193. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  194. data/spec/rspec/core/resources/formatter_specs.rb +0 -60
  195. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  196. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  197. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  198. data/spec/rspec/core/runner_spec.rb +0 -82
  199. data/spec/rspec/core/shared_context_spec.rb +0 -114
  200. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
  201. data/spec/rspec/core/shared_example_group_spec.rb +0 -138
  202. data/spec/rspec/core/world_spec.rb +0 -142
  203. data/spec/rspec/core_spec.rb +0 -108
  204. data/spec/spec_helper.rb +0 -135
  205. data/spec/support/config_options_helper.rb +0 -15
  206. data/spec/support/helper_methods.rb +0 -55
  207. data/spec/support/in_sub_process.rb +0 -37
  208. data/spec/support/isolate_load_path_mutation.rb +0 -6
  209. data/spec/support/isolated_directory.rb +0 -10
  210. data/spec/support/isolated_home_directory.rb +0 -16
  211. data/spec/support/matchers.rb +0 -65
  212. data/spec/support/mathn_integration_support.rb +0 -12
  213. data/spec/support/sandboxed_mock_space.rb +0 -116
  214. data/spec/support/shared_example_groups.rb +0 -42
  215. data/spec/support/silence_dsl_deprecations.rb +0 -32
  216. data/spec/support/spec_files.rb +0 -44
@@ -1,294 +0,0 @@
1
- Feature: shared examples
2
-
3
- Shared examples let you describe behaviour of types or modules. When
4
- declared, a shared group's content is stored. It is only realized in the
5
- context of another example group, which provides any context the shared group
6
- needs to run.
7
-
8
- A shared group is included in another group using any of:
9
-
10
- include_examples "name" # include the examples in the current context
11
- it_behaves_like "name" # include the examples in a nested context
12
- it_should_behave_like "name" # include the examples in a nested context
13
- matching metadata # include the examples in the current context
14
-
15
- WARNING: Files containing shared groups must be loaded before the files that
16
- use them. While there are conventions to handle this, RSpec does _not_ do
17
- anything special (like autoload). Doing so would require a strict naming
18
- convention for files that would break existing suites.
19
-
20
- CONVENTIONS:
21
-
22
- 1. The simplest approach is to require files with shared examples explicitly
23
- from the files that use them. Keep in mind that RSpec adds the `spec`
24
- directory to the `LOAD_PATH`, so you can say `require
25
- 'shared_examples_for_widgets'` to require a file at
26
- `#{PROJECT_ROOT}/spec/shared_examples_for_widgets.rb`.
27
-
28
- 2. Put files containing shared examples in `spec/support/` and require files
29
- in that directory from `spec/spec_helper.rb`:
30
-
31
- Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
32
-
33
- This is included in the generated `spec/spec_helper.rb` file in
34
- `rspec-rails`
35
-
36
- 3. When all of the groups that include the shared group, just declare
37
- the shared group in the same file.
38
-
39
- Scenario: shared examples group included in two groups in one file
40
- Given a file named "collection_spec.rb" with:
41
- """ruby
42
- require "set"
43
-
44
- shared_examples "a collection" do
45
- let(:collection) { described_class.new([7, 2, 4]) }
46
-
47
- context "initialized with 3 items" do
48
- it "says it has three items" do
49
- collection.size.should eq(3)
50
- end
51
- end
52
-
53
- describe "#include?" do
54
- context "with an an item that is in the collection" do
55
- it "returns true" do
56
- collection.include?(7).should be_truthy
57
- end
58
- end
59
-
60
- context "with an an item that is not in the collection" do
61
- it "returns false" do
62
- collection.include?(9).should be_falsey
63
- end
64
- end
65
- end
66
- end
67
-
68
- describe Array do
69
- it_behaves_like "a collection"
70
- end
71
-
72
- describe Set do
73
- it_behaves_like "a collection"
74
- end
75
- """
76
- When I run `rspec collection_spec.rb --format documentation`
77
- Then the examples should all pass
78
- And the output should contain:
79
- """
80
- Array
81
- behaves like a collection
82
- initialized with 3 items
83
- says it has three items
84
- #include?
85
- with an an item that is in the collection
86
- returns true
87
- with an an item that is not in the collection
88
- returns false
89
-
90
- Set
91
- behaves like a collection
92
- initialized with 3 items
93
- says it has three items
94
- #include?
95
- with an an item that is in the collection
96
- returns true
97
- with an an item that is not in the collection
98
- returns false
99
- """
100
-
101
- Scenario: Providing context to a shared group using a block
102
- Given a file named "shared_example_group_spec.rb" with:
103
- """ruby
104
- require "set"
105
-
106
- shared_examples "a collection object" do
107
- describe "<<" do
108
- it "adds objects to the end of the collection" do
109
- collection << 1
110
- collection << 2
111
- expect(collection.to_a).to match_array([1, 2])
112
- end
113
- end
114
- end
115
-
116
- describe Array do
117
- it_behaves_like "a collection object" do
118
- let(:collection) { Array.new }
119
- end
120
- end
121
-
122
- describe Set do
123
- it_behaves_like "a collection object" do
124
- let(:collection) { Set.new }
125
- end
126
- end
127
- """
128
- When I run `rspec shared_example_group_spec.rb --format documentation`
129
- Then the examples should all pass
130
- And the output should contain:
131
- """
132
- Array
133
- behaves like a collection object
134
- <<
135
- adds objects to the end of the collection
136
-
137
- Set
138
- behaves like a collection object
139
- <<
140
- adds objects to the end of the collection
141
- """
142
-
143
- Scenario: Passing parameters to a shared example group
144
- Given a file named "shared_example_group_params_spec.rb" with:
145
- """ruby
146
- shared_examples "a measurable object" do |measurement, measurement_methods|
147
- measurement_methods.each do |measurement_method|
148
- it "should return #{measurement} from ##{measurement_method}" do
149
- subject.send(measurement_method).should == measurement
150
- end
151
- end
152
- end
153
-
154
- describe Array, "with 3 items" do
155
- subject { [1, 2, 3] }
156
- it_should_behave_like "a measurable object", 3, [:size, :length]
157
- end
158
-
159
- describe String, "of 6 characters" do
160
- subject { "FooBar" }
161
- it_should_behave_like "a measurable object", 6, [:size, :length]
162
- end
163
- """
164
- When I run `rspec shared_example_group_params_spec.rb --format documentation`
165
- Then the examples should all pass
166
- And the output should contain:
167
- """
168
- Array with 3 items
169
- it should behave like a measurable object
170
- should return 3 from #size
171
- should return 3 from #length
172
-
173
- String of 6 characters
174
- it should behave like a measurable object
175
- should return 6 from #size
176
- should return 6 from #length
177
- """
178
-
179
- Scenario: Aliasing "it_should_behave_like" to "it_has_behavior"
180
- Given a file named "shared_example_group_spec.rb" with:
181
- """ruby
182
- RSpec.configure do |c|
183
- c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
184
- end
185
-
186
- shared_examples 'sortability' do
187
- it 'responds to <=>' do
188
- sortable.should respond_to(:<=>)
189
- end
190
- end
191
-
192
- describe String do
193
- it_has_behavior 'sortability' do
194
- let(:sortable) { 'sample string' }
195
- end
196
- end
197
- """
198
- When I run `rspec shared_example_group_spec.rb --format documentation`
199
- Then the examples should all pass
200
- And the output should contain:
201
- """
202
- String
203
- has behavior: sortability
204
- responds to <=>
205
- """
206
-
207
- Scenario: Sharing metadata automatically includes shared example groups
208
- Given a file named "shared_example_metadata_spec.rb" with:
209
- """ruby
210
- shared_examples "shared stuff", :a => :b do
211
- it 'runs wherever the metadata is shared' do
212
- end
213
- end
214
-
215
- describe String, :a => :b do
216
- end
217
- """
218
- When I run `rspec shared_example_metadata_spec.rb`
219
- Then the output should contain:
220
- """
221
- 1 example, 0 failures
222
- """
223
-
224
- Scenario: Shared examples are nestable by context
225
- Given a file named "context_specific_examples_spec.rb" with:
226
- """Ruby
227
- describe "shared examples" do
228
- context "per context" do
229
-
230
- shared_examples "shared examples are nestable" do
231
- specify { expect(true).to eq true }
232
- end
233
-
234
- it_behaves_like "shared examples are nestable"
235
- end
236
- end
237
- """
238
- When I run `rspec context_specific_examples_spec.rb`
239
- Then the output should contain:
240
- """
241
- 1 example, 0 failures
242
- """
243
-
244
- Scenario: Shared examples are accessible from offspring contexts
245
- Given a file named "context_specific_examples_spec.rb" with:
246
- """Ruby
247
- describe "shared examples" do
248
- shared_examples "shared examples are nestable" do
249
- specify { expect(true).to eq true }
250
- end
251
-
252
- context "per context" do
253
- it_behaves_like "shared examples are nestable"
254
- end
255
- end
256
- """
257
- When I run `rspec context_specific_examples_spec.rb`
258
- Then the output should contain:
259
- """
260
- 1 example, 0 failures
261
- """
262
- And the output should not contain:
263
- """
264
- Accessing shared_examples defined across contexts is deprecated
265
- """
266
-
267
- Scenario: Shared examples are isolated per context
268
- Given a file named "isolated_shared_examples_spec.rb" with:
269
- """Ruby
270
- describe "shared examples" do
271
- context do
272
- shared_examples "shared examples are isolated" do
273
- specify { expect(true).to eq true }
274
- end
275
- end
276
-
277
- context do
278
- it_behaves_like "shared examples are isolated"
279
- end
280
- end
281
- """
282
- When I run `rspec isolated_shared_examples_spec.rb`
283
- Then the output should contain:
284
- """
285
- 1 example, 0 failures
286
- """
287
- But the output should contain:
288
- """
289
- Accessing shared_examples defined across contexts is deprecated
290
- """
291
- And the output should contain:
292
- """
293
- isolated_shared_examples_spec.rb:9
294
- """
@@ -1,197 +0,0 @@
1
- Feature: configure expectation framework
2
-
3
- By default, RSpec is configured to include rspec-expectations for expressing
4
- desired outcomes. You can also configure RSpec to use:
5
-
6
- * rspec/expectations (explicitly)
7
- * stdlib assertions **DEPRECATED: Use test/unit or minitest explicitly**
8
- * test/unit assertions
9
- * minitest assertions
10
- * any combination of the above libraries
11
-
12
- Note that when you do not use rspec-expectations, you must explicitly provide
13
- a description to every example. You cannot rely on the generated descriptions
14
- provided by rspec-expectations.
15
-
16
- Scenario: Default configuration uses rspec-expectations
17
- Given a file named "example_spec.rb" with:
18
- """ruby
19
- RSpec::Matchers.define :be_a_multiple_of do |factor|
20
- match do |actual|
21
- actual % factor == 0
22
- end
23
- end
24
-
25
- describe 6 do
26
- it { is_expected.to be_a_multiple_of 3 }
27
- end
28
- """
29
- When I run `rspec example_spec.rb`
30
- Then the examples should all pass
31
-
32
- Scenario: Configure rspec-expectations (explicitly)
33
- Given a file named "example_spec.rb" with:
34
- """ruby
35
- RSpec.configure do |config|
36
- config.expect_with :rspec
37
- end
38
-
39
- describe 5 do
40
- it "is greater than 4" do
41
- 5.should be > 4
42
- end
43
- end
44
- """
45
- When I run `rspec example_spec.rb`
46
- Then the examples should all pass
47
-
48
- @deprecated
49
- Scenario: Configure 'stdlib' assertions
50
- Given a file named "example_spec.rb" with:
51
- """ruby
52
- RSpec.configure do |config|
53
- config.expect_with :stdlib
54
- end
55
-
56
- describe 5 do
57
- it "is greater than 4" do
58
- assert 5 > 4, "expected 5 to be greater than 4"
59
- end
60
-
61
- specify { assert 5 < 6 }
62
-
63
- it "is greater than 6 (no it isn't!)" do
64
- assert 5 > 6, "errantly expected 5 to be greater than 5"
65
- end
66
- end
67
- """
68
- When I run `rspec example_spec.rb`
69
- Then the output should match:
70
- """
71
- (Test::Unit::AssertionFailedError|Mini(T|t)est::Assertion):
72
- errantly expected 5 to be greater than 5
73
- """
74
- And the output should contain "3 examples, 1 failure"
75
- And the output should contain ":stdlib is deprecated. Use :test_unit or :minitest instead"
76
-
77
- Scenario: Configure test/unit assertions
78
- Given a file named "example_spec.rb" with:
79
- """ruby
80
- RSpec.configure do |config|
81
- config.expect_with :test_unit
82
- end
83
-
84
- RSpec.describe [1] do
85
- it "is equal to [1]" do
86
- assert_equal [1], [1], "expected [1] to equal [1]"
87
- end
88
-
89
- specify { assert_not_equal [1], [] }
90
-
91
- it "is equal to [2] (intentional failure)" do
92
- assert [1] == [2], "errantly expected [2] to equal [1]"
93
- end
94
- end
95
- """
96
- When I run `rspec example_spec.rb`
97
- Then the output should match:
98
- """
99
- (Test::Unit::AssertionFailedError|Mini(T|t)est::Assertion):
100
- errantly expected \[2\] to equal \[1\]
101
- """
102
- And the output should contain "3 examples, 1 failure"
103
-
104
- Scenario: Configure minitest assertions
105
- Given a file named "example_spec.rb" with:
106
- """ruby
107
- RSpec.configure do |config|
108
- config.expect_with :minitest
109
- end
110
-
111
- RSpec.describe "Object identity" do
112
- it "the an object is the same as itself" do
113
- x = [1]
114
- assert_same x, x, "expected x to be the same x"
115
- end
116
-
117
- specify { refute_same [1], [1] }
118
-
119
- it "is empty (intentional failure)" do
120
- assert_empty [1], "errantly expected [1] to be empty"
121
- end
122
- end
123
- """
124
- When I run `rspec -b example_spec.rb`
125
- Then the output should match:
126
- """
127
- MiniT|test::Assertion:
128
- errantly expected \[1\] to be empty
129
- """
130
- And the output should contain "3 examples, 1 failure"
131
- And the output should not contain "Warning: you should require 'minitest/autorun' instead."
132
-
133
- Scenario: Configure rspec/expectations AND test/unit assertions
134
- Given a file named "example_spec.rb" with:
135
- """ruby
136
- RSpec.configure do |config|
137
- config.expect_with :rspec, :test_unit
138
- end
139
-
140
- RSpec.describe [1] do
141
- it "is equal to [1]" do
142
- assert_equal [1], [1], "expected [1] to equal [1]"
143
- end
144
-
145
- it "matches array [1]" do
146
- is_expected.to match_array([1])
147
- end
148
- end
149
- """
150
- When I run `rspec example_spec.rb`
151
- Then the examples should all pass
152
-
153
- Scenario: Configure rspec/expecations AND minitest assertions
154
- Given a file named "example_spec.rb" with:
155
- """ruby
156
- RSpec.configure do |config|
157
- config.expect_with :rspec, :minitest
158
- end
159
-
160
- RSpec.describe "Object identity" do
161
- it "two arrays are not the same object" do
162
- refute_same [1], [1]
163
- end
164
-
165
- it "an array is itself" do
166
- array = [1]
167
- expect(array).to be array
168
- end
169
- end
170
- """
171
- When I run `rspec example_spec.rb`
172
- Then the examples should all pass
173
-
174
- Scenario: Configure test/unit and minitest assertions
175
- Given a file named "example_spec.rb" with:
176
- """ruby
177
- RSpec.configure do |config|
178
- config.expect_with :test_unit, :minitest
179
- end
180
-
181
- RSpec.describe [1] do
182
- it "is equal to [1]" do
183
- assert_equal [1], [1], "expected [1] to equal [1]"
184
- end
185
-
186
- specify { assert_not_equal [1], [] }
187
-
188
- it "the an object is the same as itself" do
189
- x = [1]
190
- assert_same x, x, "expected x to be the same x"
191
- end
192
-
193
- specify { refute_same [1], [1] }
194
- end
195
- """
196
- When I run `rspec example_spec.rb`
197
- Then the examples should all pass
@@ -1,138 +0,0 @@
1
- Feature: exclusion filters
2
-
3
- You can exclude examples from a run by declaring an exclusion filter and
4
- then tagging examples, or entire groups, with that filter.
5
-
6
- If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
7
- to `true`, you can specify metadata using only symbols.
8
-
9
- Scenario: exclude an example
10
- Given a file named "spec/sample_spec.rb" with:
11
- """ruby
12
- RSpec.configure do |c|
13
- # declare an exclusion filter
14
- c.filter_run_excluding :broken => true
15
- end
16
-
17
- describe "something" do
18
- it "does one thing" do
19
- end
20
-
21
- # tag example for exclusion by adding metadata
22
- it "does another thing", :broken => true do
23
- end
24
- end
25
- """
26
- When I run `rspec ./spec/sample_spec.rb --format doc`
27
- Then the output should contain "does one thing"
28
- And the output should not contain "does another thing"
29
-
30
- Scenario: exclude a group
31
- Given a file named "spec/sample_spec.rb" with:
32
- """ruby
33
- RSpec.configure do |c|
34
- c.filter_run_excluding :broken => true
35
- end
36
-
37
- describe "group 1", :broken => true do
38
- it "group 1 example 1" do
39
- end
40
-
41
- it "group 1 example 2" do
42
- end
43
- end
44
-
45
- describe "group 2" do
46
- it "group 2 example 1" do
47
- end
48
- end
49
- """
50
- When I run `rspec ./spec/sample_spec.rb --format doc`
51
- Then the output should contain "group 2 example 1"
52
- And the output should not contain "group 1 example 1"
53
- And the output should not contain "group 1 example 2"
54
-
55
- Scenario: exclude multiple groups
56
- Given a file named "spec/sample_spec.rb" with:
57
- """ruby
58
- RSpec.configure do |c|
59
- c.filter_run_excluding :broken => true
60
- end
61
-
62
- describe "group 1", :broken => true do
63
- before(:all) do
64
- raise "you should not see me"
65
- end
66
-
67
- it "group 1 example 1" do
68
- end
69
-
70
- it "group 1 example 2" do
71
- end
72
- end
73
-
74
- describe "group 2", :broken => true do
75
- before(:each) do
76
- raise "you should not see me"
77
- end
78
-
79
- it "group 2 example 1" do
80
- end
81
- end
82
- """
83
- When I run `rspec ./spec/sample_spec.rb --format doc`
84
- Then the process should succeed even though no examples were run
85
- And the output should not contain "group 1"
86
- And the output should not contain "group 2"
87
-
88
- Scenario: before/after(:all) hooks in excluded example group are not run
89
- Given a file named "spec/before_after_all_exclusion_filter_spec.rb" with:
90
- """ruby
91
- RSpec.configure do |c|
92
- c.filter_run_excluding :broken => true
93
- end
94
-
95
- describe "group 1" do
96
- before(:all) { puts "before all in included group" }
97
- after(:all) { puts "after all in included group" }
98
-
99
- it "group 1 example" do
100
- end
101
- end
102
-
103
- describe "group 2", :broken => true do
104
- before(:all) { puts "before all in excluded group" }
105
- after(:all) { puts "after all in excluded group" }
106
-
107
- context "context 1" do
108
- it "group 2 context 1 example 1" do
109
- end
110
- end
111
- end
112
- """
113
- When I run `rspec ./spec/before_after_all_exclusion_filter_spec.rb`
114
- Then the output should contain "before all in included group"
115
- And the output should contain "after all in included group"
116
- And the output should not contain "before all in excluded group"
117
- And the output should not contain "after all in excluded group"
118
-
119
- Scenario: Use symbols as metadata
120
- Given a file named "symbols_as_metadata_spec.rb" with:
121
- """ruby
122
- RSpec.configure do |c|
123
- c.treat_symbols_as_metadata_keys_with_true_values = true
124
- c.filter_run_excluding :broken
125
- end
126
-
127
- describe "something" do
128
- it "does one thing" do
129
- end
130
-
131
- # tag example for exclusion by adding metadata
132
- it "does another thing", :broken do
133
- end
134
- end
135
- """
136
- When I run `rspec symbols_as_metadata_spec.rb --format doc`
137
- Then the output should contain "does one thing"
138
- And the output should not contain "does another thing"