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,227 +0,0 @@
1
- require "spec_helper"
2
-
3
- module RSpec::Core
4
- describe "config block hook filtering" do
5
- describe "unfiltered hooks" do
6
- it "is run" do
7
- filters = []
8
- RSpec.configure do |c|
9
- c.before(:all) { filters << "before all in config"}
10
- c.around(:each) {|example| filters << "around each in config"; example.run}
11
- c.before(:each) { filters << "before each in config"}
12
- c.after(:each) { filters << "after each in config"}
13
- c.after(:all) { filters << "after all in config"}
14
- end
15
- group = ExampleGroup.describe
16
- group.example("example") {}
17
- group.run
18
- expect(filters).to eq([
19
- "before all in config",
20
- "around each in config",
21
- "before each in config",
22
- "after each in config",
23
- "after all in config"
24
- ])
25
- end
26
- end
27
-
28
- describe "hooks with single filters" do
29
-
30
- context "with no scope specified" do
31
- it "is run around|before|after :each if the filter matches the example group's filter" do
32
- filters = []
33
- RSpec.configure do |c|
34
- c.around(:match => true) {|example| filters << "around each in config"; example.run}
35
- c.before(:match => true) { filters << "before each in config"}
36
- c.after(:match => true) { filters << "after each in config"}
37
- end
38
- group = ExampleGroup.describe("group", :match => true)
39
- group.example("example") {}
40
- group.run
41
- expect(filters).to eq([
42
- "around each in config",
43
- "before each in config",
44
- "after each in config"
45
- ])
46
- end
47
- end
48
-
49
- it "is run if the filter matches the example group's filter" do
50
- filters = []
51
- RSpec.configure do |c|
52
- c.before(:all, :match => true) { filters << "before all in config"}
53
- c.around(:each, :match => true) {|example| filters << "around each in config"; example.run}
54
- c.before(:each, :match => true) { filters << "before each in config"}
55
- c.after(:each, :match => true) { filters << "after each in config"}
56
- c.after(:all, :match => true) { filters << "after all in config"}
57
- end
58
- group = ExampleGroup.describe("group", :match => true)
59
- group.example("example") {}
60
- group.run
61
- expect(filters).to eq([
62
- "before all in config",
63
- "around each in config",
64
- "before each in config",
65
- "after each in config",
66
- "after all in config"
67
- ])
68
- end
69
-
70
- it "runs before|after :all hooks on matching nested example groups" do
71
- filters = []
72
- RSpec.configure do |c|
73
- c.before(:all, :match => true) { filters << :before_all }
74
- c.after(:all, :match => true) { filters << :after_all }
75
- end
76
-
77
- example_1_filters = example_2_filters = nil
78
-
79
- group = ExampleGroup.describe "group" do
80
- it("example 1") { example_1_filters = filters.dup }
81
- describe "subgroup", :match => true do
82
- it("example 2") { example_2_filters = filters.dup }
83
- end
84
- end
85
- group.run
86
-
87
- expect(example_1_filters).to be_empty
88
- expect(example_2_filters).to eq([:before_all])
89
- expect(filters).to eq([:before_all, :after_all])
90
- end
91
-
92
- it "runs before|after :all hooks only on the highest level group that matches the filter" do
93
- filters = []
94
- RSpec.configure do |c|
95
- c.before(:all, :match => true) { filters << :before_all }
96
- c.after(:all, :match => true) { filters << :after_all }
97
- end
98
-
99
- example_1_filters = example_2_filters = example_3_filters = nil
100
-
101
- group = ExampleGroup.describe "group", :match => true do
102
- it("example 1") { example_1_filters = filters.dup }
103
- describe "subgroup", :match => true do
104
- it("example 2") { example_2_filters = filters.dup }
105
- describe "sub-subgroup", :match => true do
106
- it("example 3") { example_3_filters = filters.dup }
107
- end
108
- end
109
- end
110
- group.run
111
-
112
- expect(example_1_filters).to eq([:before_all])
113
- expect(example_2_filters).to eq([:before_all])
114
- expect(example_3_filters).to eq([:before_all])
115
-
116
- expect(filters).to eq([:before_all, :after_all])
117
- end
118
-
119
- it "does not run if the filter doesn't match the example group's filter" do
120
- filters = []
121
- RSpec.configure do |c|
122
- c.before(:all, :match => false) { filters << "before all in config"}
123
- c.around(:each, :match => false) {|example| filters << "around each in config"; example.run}
124
- c.before(:each, :match => false) { filters << "before each in config"}
125
- c.after(:each, :match => false) { filters << "after each in config"}
126
- c.after(:all, :match => false) { filters << "after all in config"}
127
- end
128
- group = ExampleGroup.describe("group", :match => true)
129
- group.example("example") {}
130
- group.run
131
- expect(filters).to eq([])
132
- end
133
-
134
- context "when the hook filters apply to individual examples instead of example groups" do
135
- let(:each_filters) { [] }
136
- let(:all_filters) { [] }
137
-
138
- let(:group) do
139
- md = example_metadata
140
- ExampleGroup.describe do
141
- it("example", md) { }
142
- end
143
- end
144
-
145
- def filters
146
- each_filters + all_filters
147
- end
148
-
149
- before(:each) do
150
- af, ef = all_filters, each_filters
151
-
152
- RSpec.configure do |c|
153
- c.before(:all, :foo => :bar) { af << "before all in config"}
154
- c.around(:each, :foo => :bar) {|example| ef << "around each in config"; example.run}
155
- c.before(:each, :foo => :bar) { ef << "before each in config"}
156
- c.after(:each, :foo => :bar) { ef << "after each in config"}
157
- c.after(:all, :foo => :bar) { af << "after all in config"}
158
- end
159
-
160
- group.run
161
- end
162
-
163
- describe 'an example with matching metadata' do
164
- let(:example_metadata) { { :foo => :bar } }
165
-
166
- it "runs the `:each` hooks" do
167
- expect(each_filters).to eq([
168
- 'around each in config',
169
- 'before each in config',
170
- 'after each in config'
171
- ])
172
- end
173
-
174
- it "does not run the `:all` hooks" do
175
- expect(all_filters).to be_empty
176
- end
177
- end
178
-
179
- describe 'an example without matching metadata' do
180
- let(:example_metadata) { { :foo => :bazz } }
181
-
182
- it "does not run any of the hooks" do
183
- expect(filters).to be_empty
184
- end
185
- end
186
- end
187
- end
188
-
189
- describe "hooks with multiple filters" do
190
- it "is run if all hook filters match the group's filters" do
191
- filters = []
192
- RSpec.configure do |c|
193
- c.before(:all, :one => 1) { filters << "before all in config"}
194
- c.around(:each, :two => 2, :one => 1) {|example| filters << "around each in config"; example.run}
195
- c.before(:each, :one => 1, :two => 2) { filters << "before each in config"}
196
- c.after(:each, :one => 1, :two => 2, :three => 3) { filters << "after each in config"}
197
- c.after(:all, :one => 1, :three => 3) { filters << "after all in config"}
198
- end
199
- group = ExampleGroup.describe("group", :one => 1, :two => 2, :three => 3)
200
- group.example("example") {}
201
- group.run
202
- expect(filters).to eq([
203
- "before all in config",
204
- "around each in config",
205
- "before each in config",
206
- "after each in config",
207
- "after all in config"
208
- ])
209
- end
210
-
211
- it "does not run if some hook filters don't match the group's filters" do
212
- filters = []
213
- RSpec.configure do |c|
214
- c.before(:all, :one => 1, :four => 4) { filters << "before all in config"}
215
- c.around(:each, :two => 2, :four => 4) {|example| filters << "around each in config"; example.run}
216
- c.before(:each, :one => 1, :two => 2, :four => 4) { filters << "before each in config"}
217
- c.after(:each, :one => 1, :two => 2, :three => 3, :four => 4) { filters << "after each in config"}
218
- c.after(:all, :one => 1, :three => 3, :four => 4) { filters << "after all in config"}
219
- end
220
- group = ExampleGroup.describe("group", :one => 1, :two => 2, :three => 3)
221
- group.example("example") {}
222
- group.run
223
- expect(filters).to eq([])
224
- end
225
- end
226
- end
227
- end
@@ -1,269 +0,0 @@
1
- require "spec_helper"
2
-
3
- module RSpec::Core
4
- describe Hooks do
5
- class HooksHost
6
- include Hooks
7
- end
8
-
9
- [:before, :after, :around].each do |type|
10
- [:each, :all].each do |scope|
11
- next if type == :around && scope == :all
12
-
13
- describe "##{type}(#{scope})" do
14
- it_behaves_like "metadata hash builder" do
15
- define_method :metadata_hash do |*args|
16
- instance = HooksHost.new
17
- args.unshift scope if scope
18
- hooks = instance.send(type, *args) {}
19
- hooks.first.options
20
- end
21
- end
22
- end
23
- end
24
-
25
- [true, false].each do |config_value|
26
- context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to #{config_value}" do
27
- before(:each) do
28
- Kernel.stub(:warn)
29
- allow_deprecation unless config_value
30
- RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = config_value }
31
- end
32
-
33
- describe "##{type}(no scope)" do
34
- let(:instance) { HooksHost.new }
35
-
36
- it "defaults to :each scope if no arguments are given" do
37
- hooks = instance.send(type) {}
38
- hook = hooks.first
39
- expect(instance.hooks[type][:each]).to include(hook)
40
- end
41
-
42
- it "defaults to :each scope if the only argument is a metadata hash" do
43
- hooks = instance.send(type, :foo => :bar) {}
44
- hook = hooks.first
45
- expect(instance.hooks[type][:each]).to include(hook)
46
- end
47
-
48
- it "raises an error if only metadata symbols are given as arguments" do
49
- expect { instance.send(type, :foo, :bar) {} }.to raise_error(ArgumentError)
50
- end
51
- end
52
- end
53
- end
54
- end
55
-
56
- [:before, :after].each do |type|
57
- [:each, :all, :suite].each do |scope|
58
- [true, false].each do |config_value|
59
- context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to #{config_value}" do
60
- before(:each) do
61
- allow_deprecation unless config_value
62
- RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = config_value }
63
- end
64
-
65
- describe "##{type}(#{scope.inspect})" do
66
- let(:instance) { HooksHost.new }
67
- let!(:hook) do
68
- hooks = instance.send(type, scope) {}
69
- hooks.first
70
- end
71
-
72
- it "does not make #{scope.inspect} a metadata key" do
73
- expect(hook.options).to be_empty
74
- end
75
-
76
- it "is scoped to #{scope.inspect}" do
77
- expect(instance.hooks[type][scope]).to include(hook)
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
84
-
85
- describe "#around" do
86
- context "when not running the example within the around block" do
87
- it "does not run the example" do
88
- examples = []
89
- group = ExampleGroup.describe do
90
- around do |example|
91
- end
92
- it "foo" do
93
- examples << self
94
- end
95
- end
96
- group.run
97
- expect(examples).to have(0).example
98
- end
99
- end
100
-
101
- context "when running the example within the around block" do
102
- it "runs the example" do
103
- examples = []
104
- group = ExampleGroup.describe do
105
- around do |example|
106
- example.run
107
- end
108
- it "foo" do
109
- examples << self
110
- end
111
- end
112
- group.run
113
- expect(examples).to have(1).example
114
- end
115
- end
116
-
117
- context "when running the example within a block passed to a method" do
118
- it "runs the example" do
119
- examples = []
120
- group = ExampleGroup.describe do
121
- def yielder
122
- yield
123
- end
124
-
125
- around do |example|
126
- yielder { example.run }
127
- end
128
- it "foo" do
129
- examples << self
130
- end
131
- end
132
- group.run
133
- expect(examples).to have(1).example
134
- end
135
- end
136
- end
137
-
138
- [:all, :each].each do |scope|
139
- describe "prepend_before(#{scope})" do
140
- it "adds to the front of the list of before(:#{scope}) hooks" do
141
- messages = []
142
-
143
- RSpec.configure { |config| config.before(scope) { messages << "config 3" } }
144
- RSpec.configure { |config| config.prepend_before(scope) { messages << "config 2" } }
145
- RSpec.configure { |config| config.before(scope) { messages << "config 4" } }
146
- RSpec.configure { |config| config.prepend_before(scope) { messages << "config 1" } }
147
-
148
- group = ExampleGroup.describe { example {} }
149
- group.before(scope) { messages << "group 3" }
150
- group.prepend_before(scope) { messages << "group 2" }
151
- group.before(scope) { messages << "group 4" }
152
- group.prepend_before(scope) { messages << "group 1" }
153
-
154
- group.run
155
-
156
- expect(messages).to eq([
157
- 'group 1',
158
- 'group 2',
159
- 'config 1',
160
- 'config 2',
161
- 'config 3',
162
- 'config 4',
163
- 'group 3',
164
- 'group 4'
165
- ])
166
- end
167
- end
168
-
169
- describe "append_before(#{scope})" do
170
- it "adds to the back of the list of before(:#{scope}) hooks (same as `before`)" do
171
- messages = []
172
-
173
- RSpec.configure { |config| config.before(scope) { messages << "config 1" } }
174
- RSpec.configure { |config| config.append_before(scope) { messages << "config 2" } }
175
- RSpec.configure { |config| config.before(scope) { messages << "config 3" } }
176
-
177
- group = ExampleGroup.describe { example {} }
178
- group.before(scope) { messages << "group 1" }
179
- group.append_before(scope) { messages << "group 2" }
180
- group.before(scope) { messages << "group 3" }
181
-
182
- group.run
183
-
184
- expect(messages).to eq([
185
- 'config 1',
186
- 'config 2',
187
- 'config 3',
188
- 'group 1',
189
- 'group 2',
190
- 'group 3'
191
- ])
192
- end
193
- end
194
-
195
- describe "prepend_after(#{scope})" do
196
- it "adds to the front of the list of after(:#{scope}) hooks (same as `after`)" do
197
- messages = []
198
-
199
- RSpec.configure { |config| config.after(scope) { messages << "config 3" } }
200
- RSpec.configure { |config| config.prepend_after(scope) { messages << "config 2" } }
201
- RSpec.configure { |config| config.after(scope) { messages << "config 1" } }
202
-
203
- group = ExampleGroup.describe { example {} }
204
- group.after(scope) { messages << "group 3" }
205
- group.prepend_after(scope) { messages << "group 2" }
206
- group.after(scope) { messages << "group 1" }
207
-
208
- group.run
209
-
210
- expect(messages).to eq([
211
- 'group 1',
212
- 'group 2',
213
- 'group 3',
214
- 'config 1',
215
- 'config 2',
216
- 'config 3'
217
- ])
218
- end
219
- end
220
-
221
- describe "append_after(#{scope})" do
222
- it "adds to the back of the list of after(:#{scope}) hooks" do
223
- messages = []
224
-
225
- RSpec.configure { |config| config.after(scope) { messages << "config 2" } }
226
- RSpec.configure { |config| config.append_after(scope) { messages << "config 3" } }
227
- RSpec.configure { |config| config.after(scope) { messages << "config 1" } }
228
- RSpec.configure { |config| config.append_after(scope) { messages << "config 4" } }
229
-
230
- group = ExampleGroup.describe { example {} }
231
- group.after(scope) { messages << "group 2" }
232
- group.append_after(scope) { messages << "group 3" }
233
- group.after(scope) { messages << "group 1" }
234
- group.append_after(scope) { messages << "group 4" }
235
-
236
- group.run
237
-
238
- expect(messages).to eq([
239
- 'group 1',
240
- 'group 2',
241
- 'config 1',
242
- 'config 2',
243
- 'config 3',
244
- 'config 4',
245
- 'group 3',
246
- 'group 4'
247
- ])
248
- end
249
- end
250
- end
251
-
252
- describe "lambda" do
253
- it "can be used as a hook" do
254
- messages = []
255
- count = 0
256
- hook = lambda {|e| messages << "hook #{count = count + 1}"; e.run }
257
-
258
- RSpec.configure do |c|
259
- c.around(:each, &hook)
260
- c.around(:each, &hook)
261
- end
262
-
263
- group = ExampleGroup.describe { example { messages << "example" } }
264
- group.run
265
- expect(messages).to eq ["hook 1", "hook 2", "example"]
266
- end
267
- end
268
- end
269
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "extensions" do
4
- describe "debugger" do
5
- it "is defined on Kernel" do
6
- expect(Kernel).to respond_to(:debugger)
7
- end
8
- end
9
- end