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,263 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/deprecation_formatter'
3
- require 'tempfile'
4
-
5
- module RSpec::Core::Formatters
6
- describe DeprecationFormatter do
7
- let(:deprecation_stream) { StringIO.new }
8
- let(:summary_stream) { StringIO.new }
9
- let(:formatter) { DeprecationFormatter.new(deprecation_stream, summary_stream) }
10
-
11
- def with_start_defined_on_kernel
12
- return yield if ::Kernel.method_defined?(:start)
13
-
14
- begin
15
- ::Kernel.module_eval { def start(*); raise "boom"; end }
16
- yield
17
- ensure
18
- ::Kernel.module_eval { undef start }
19
- end
20
- end
21
-
22
- it 'does not blow up when `Kernel` defines `start`' do
23
- with_start_defined_on_kernel do
24
- reporter = ::RSpec::Core::Reporter.new(formatter)
25
- reporter.start(3)
26
- end
27
- end
28
-
29
- describe "#deprecation" do
30
- let(:formatter) { DeprecationFormatter.new(deprecation_stream, summary_stream) }
31
- let(:summary_stream) { StringIO.new }
32
-
33
- context "with a File deprecation_stream" do
34
- let(:deprecation_stream) { File.open("#{Dir.tmpdir}/deprecation_summary_example_output", "w+") }
35
-
36
- it "prints a message if provided, ignoring other data" do
37
- formatter.deprecation(:message => "this message", :deprecated => "x", :replacement => "y", :call_site => "z")
38
- deprecation_stream.rewind
39
- expect(deprecation_stream.read).to eq "this message\n"
40
- end
41
-
42
- it "surrounds multiline messages in fenceposts" do
43
- multiline_message = <<-EOS.gsub(/^\s+\|/, '')
44
- |line one
45
- |line two
46
- EOS
47
- formatter.deprecation(:message => multiline_message)
48
- deprecation_stream.rewind
49
-
50
- expected = <<-EOS.gsub(/^\s+\|/, '')
51
- |--------------------------------------------------------------------------------
52
- |line one
53
- |line two
54
- |--------------------------------------------------------------------------------
55
- EOS
56
- expect(deprecation_stream.read).to eq expected
57
- end
58
-
59
- it "includes the method" do
60
- formatter.deprecation(:deprecated => "i_am_deprecated")
61
- deprecation_stream.rewind
62
- expect(deprecation_stream.read).to match(/i_am_deprecated is deprecated/)
63
- end
64
-
65
- it "includes the replacement" do
66
- formatter.deprecation(:replacement => "use_me")
67
- deprecation_stream.rewind
68
- expect(deprecation_stream.read).to match(/Use use_me instead/)
69
- end
70
-
71
- it "includes the call site if provided" do
72
- formatter.deprecation(:call_site => "somewhere")
73
- deprecation_stream.rewind
74
- expect(deprecation_stream.read).to match(/Called from somewhere/)
75
- end
76
- end
77
-
78
- context "with an IO deprecation stream" do
79
- let(:deprecation_stream) { StringIO.new }
80
-
81
- it "prints nothing" do
82
- 5.times { formatter.deprecation(:deprecated => 'i_am_deprecated') }
83
- expect(deprecation_stream.string).to eq ""
84
- end
85
- end
86
- end
87
-
88
- describe "#deprecation_summary" do
89
- let(:formatter) { DeprecationFormatter.new(deprecation_stream, summary_stream) }
90
- let(:summary_stream) { StringIO.new }
91
-
92
- context "with a File deprecation_stream" do
93
- let(:deprecation_stream) { File.open("#{Dir.tmpdir}/deprecation_summary_example_output", "w") }
94
-
95
- it "prints a count of the deprecations" do
96
- formatter.deprecation(:deprecated => 'i_am_deprecated')
97
- formatter.deprecation_summary
98
- expect(summary_stream.string).to match(/1 deprecation logged to .*deprecation_summary_example_output/)
99
- end
100
-
101
- it "pluralizes the reported deprecation count for more than one deprecation" do
102
- formatter.deprecation(:deprecated => 'i_am_deprecated')
103
- formatter.deprecation(:deprecated => 'i_am_deprecated_also')
104
- formatter.deprecation_summary
105
- expect(summary_stream.string).to match(/2 deprecations/)
106
- end
107
-
108
- it "is not printed when there are no deprecations" do
109
- formatter.deprecation_summary
110
- expect(summary_stream.string).to eq ""
111
- end
112
-
113
- it 'uses synchronized/non-buffered output to work around odd duplicate output behavior we have observed' do
114
- expect {
115
- formatter.deprecation(:deprecated => 'foo')
116
- }.to change { deprecation_stream.sync }.from(false).to(true)
117
- end
118
-
119
- it 'does not print duplicate messages' do
120
- 3.times { formatter.deprecation(:deprecated => 'foo') }
121
- formatter.deprecation_summary
122
-
123
- expect(summary_stream.string).to match(/1 deprecation/)
124
- expect(File.read(deprecation_stream.path)).to eq("foo is deprecated.\n#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}")
125
- end
126
- end
127
-
128
- context "with an Error deprecation_stream" do
129
- let(:deprecation_stream) { DeprecationFormatter::RaiseErrorStream.new }
130
-
131
- it 'prints a summary of the number of deprecations found' do
132
- expect { formatter.deprecation(:deprecated => 'foo') }.to raise_error(RSpec::Core::DeprecationError)
133
-
134
- formatter.deprecation_summary
135
-
136
- expect(summary_stream.string).to eq("\n1 deprecation found.\n")
137
- end
138
-
139
- it 'pluralizes the count when it is greater than 1' do
140
- expect { formatter.deprecation(:deprecated => 'foo') }.to raise_error(RSpec::Core::DeprecationError)
141
- expect { formatter.deprecation(:deprecated => 'bar') }.to raise_error(RSpec::Core::DeprecationError)
142
-
143
- formatter.deprecation_summary
144
-
145
- expect(summary_stream.string).to eq("\n2 deprecations found.\n")
146
- end
147
- end
148
-
149
- context "with an IO deprecation_stream" do
150
- let(:deprecation_stream) { StringIO.new }
151
-
152
- it "groups similar deprecations together" do
153
- formatter.deprecation(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:1")
154
- formatter.deprecation(:deprecated => 'i_am_a_different_deprecation')
155
- formatter.deprecation(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:2")
156
- formatter.deprecation_summary
157
-
158
- expected = <<-EOS.gsub(/^\s+\|/, '')
159
- |
160
- |Deprecation Warnings:
161
- |
162
- |i_am_a_different_deprecation is deprecated.
163
- |
164
- |i_am_deprecated is deprecated. Called from foo.rb:1.
165
- |i_am_deprecated is deprecated. Called from foo.rb:2.
166
- |
167
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
168
- EOS
169
- expect(deprecation_stream.string).to eq expected.chomp
170
- end
171
-
172
- it "limits the deprecation warnings after 3 calls" do
173
- 5.times { |i| formatter.deprecation(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:#{i + 1}") }
174
- formatter.deprecation_summary
175
- expected = <<-EOS.gsub(/^\s+\|/, '')
176
- |
177
- |Deprecation Warnings:
178
- |
179
- |i_am_deprecated is deprecated. Called from foo.rb:1.
180
- |i_am_deprecated is deprecated. Called from foo.rb:2.
181
- |i_am_deprecated is deprecated. Called from foo.rb:3.
182
- |Too many uses of deprecated 'i_am_deprecated'. #{DeprecationFormatter::DEPRECATION_STREAM_NOTICE}
183
- |
184
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
185
- EOS
186
- expect(deprecation_stream.string).to eq expected.chomp
187
- end
188
-
189
- it "limits deprecations warnings by optional type" do
190
- 5.times {|i|
191
- formatter.deprecation(
192
- :deprecated => "i_am_deprecated #{i}",
193
- :call_site => "foo.rb:#{i + 1}",
194
- :type => 'i_am_deprecated'
195
- )
196
- }
197
- formatter.deprecation_summary
198
-
199
- expected = <<-EOS.gsub(/^\s+\|/, '')
200
- |
201
- |Deprecation Warnings:
202
- |
203
- |i_am_deprecated 0 is deprecated. Called from foo.rb:1.
204
- |i_am_deprecated 1 is deprecated. Called from foo.rb:2.
205
- |i_am_deprecated 2 is deprecated. Called from foo.rb:3.
206
- |Too many uses of deprecated 'i_am_deprecated'. #{DeprecationFormatter::DEPRECATION_STREAM_NOTICE}
207
- |
208
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
209
- EOS
210
- expect(deprecation_stream.string).to eq expected.chomp
211
- end
212
-
213
-
214
- it "limits :message deprecation warnings with different callsites after 3 calls" do
215
- 5.times do |n|
216
- message = "This is a long string with some callsite info: /path/#{n}/to/some/file.rb:2#{n}3. And some more stuff can come after."
217
- formatter.deprecation(:message => message)
218
- end
219
- formatter.deprecation_summary
220
- expected = <<-EOS.gsub(/^\s+\|/, '')
221
- |
222
- |Deprecation Warnings:
223
- |
224
- |This is a long string with some callsite info: /path/0/to/some/file.rb:203. And some more stuff can come after.
225
- |This is a long string with some callsite info: /path/1/to/some/file.rb:213. And some more stuff can come after.
226
- |This is a long string with some callsite info: /path/2/to/some/file.rb:223. And some more stuff can come after.
227
- |Too many similar deprecation messages reported, disregarding further reports. #{DeprecationFormatter::DEPRECATION_STREAM_NOTICE}
228
- |
229
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
230
- EOS
231
- expect(deprecation_stream.string).to eq expected.chomp
232
- end
233
-
234
- it "prints the true deprecation count to the summary_stream" do
235
- 5.times { |i| formatter.deprecation(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:#{i + 1}") }
236
- 5.times do |n|
237
- formatter.deprecation(:message => "callsite info: /path/#{n}/to/some/file.rb:2#{n}3. And some more stuff")
238
- end
239
- formatter.deprecation_summary
240
- expect(summary_stream.string).to match(/10 deprecation warnings total/)
241
- end
242
-
243
- it 'does not print duplicate messages' do
244
- 3.times { formatter.deprecation(:deprecated => 'foo') }
245
- formatter.deprecation_summary
246
-
247
- expect(summary_stream.string).to match(/1 deprecation/)
248
-
249
- expected = <<-EOS.gsub(/^\s+\|/, '')
250
- |
251
- |Deprecation Warnings:
252
- |
253
- |foo is deprecated.
254
- |
255
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
256
- EOS
257
-
258
- expect(deprecation_stream.string).to eq expected.chomp
259
- end
260
- end
261
- end
262
- end
263
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/documentation_formatter'
3
-
4
- module RSpec::Core::Formatters
5
- describe DocumentationFormatter do
6
-
7
- it "numbers the failures" do
8
-
9
- examples = [
10
- double("example 1",
11
- :description => "first example",
12
- :execution_result => {:status => 'failed', :exception => Exception.new }
13
- ),
14
- double("example 2",
15
- :description => "second example",
16
- :execution_result => {:status => 'failed', :exception => Exception.new }
17
- )
18
- ]
19
-
20
- output = StringIO.new
21
- RSpec.configuration.stub(:color_enabled?) { false }
22
-
23
- formatter = RSpec::Core::Formatters::DocumentationFormatter.new(output)
24
-
25
- examples.each {|e| formatter.example_failed(e) }
26
-
27
- expect(output.string).to match(/first example \(FAILED - 1\)/m)
28
- expect(output.string).to match(/second example \(FAILED - 2\)/m)
29
- end
30
-
31
- it "represents nested group using hierarchy tree" do
32
- output = StringIO.new
33
- RSpec.configuration.stub(:color_enabled?) { false }
34
-
35
- formatter = RSpec::Core::Formatters::DocumentationFormatter.new(output)
36
-
37
- group = RSpec::Core::ExampleGroup.describe("root")
38
- context1 = group.describe("context 1")
39
- context1.example("nested example 1.1"){}
40
- context1.example("nested example 1.2"){}
41
-
42
- context11 = context1.describe("context 1.1")
43
- context11.example("nested example 1.1.1"){}
44
- context11.example("nested example 1.1.2"){}
45
-
46
- context2 = group.describe("context 2")
47
- context2.example("nested example 2.1"){}
48
- context2.example("nested example 2.2"){}
49
-
50
- group.run(RSpec::Core::Reporter.new(formatter))
51
-
52
- expect(output.string).to eql("
53
- root
54
- context 1
55
- nested example 1.1
56
- nested example 1.2
57
- context 1.1
58
- nested example 1.1.1
59
- nested example 1.1.2
60
- context 2
61
- nested example 2.1
62
- nested example 2.2
63
- ")
64
- end
65
-
66
- it "strips whitespace for each row" do
67
- output = StringIO.new
68
- RSpec.configuration.stub(:color_enabled?) { false }
69
-
70
- formatter = RSpec::Core::Formatters::DocumentationFormatter.new(output)
71
-
72
- group = RSpec::Core::ExampleGroup.describe(" root ")
73
- context1 = group.describe(" nested ")
74
- context1.example(" example 1 ") {}
75
- context1.example(" example 2 ", :pending => true){}
76
- context1.example(" example 3 ") { fail }
77
-
78
- group.run(RSpec::Core::Reporter.new(formatter))
79
-
80
- expect(output.string).to eql("
81
- root
82
- nested
83
- example 1
84
- example 2 (PENDING: No reason given)
85
- example 3 (FAILED - 1)
86
- ")
87
- end
88
- end
89
- end
@@ -1,104 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/helpers'
3
-
4
- describe RSpec::Core::Formatters::Helpers do
5
- let(:helper) { Object.new.extend(RSpec::Core::Formatters::Helpers) }
6
-
7
- describe "format duration" do
8
- context '< 1' do
9
- it "returns '0.xxxxx seconds' formatted string" do
10
- expect(helper.format_duration(0.123456)).to eq("0.12346 seconds")
11
- end
12
- end
13
-
14
- context '> 1 and < 60' do
15
- it "returns 'xx.xx seconds' formatted string" do
16
- expect(helper.format_duration(45.51)).to eq("45.51 seconds")
17
- end
18
- end
19
-
20
- context '> 60 and < 120' do
21
- it "returns 'x minute xx.xx seconds' formatted string" do
22
- expect(helper.format_duration(70.14)).to eq("1 minute 10.14 seconds")
23
- end
24
- end
25
-
26
- context '> 120 and < 300' do
27
- it "returns 'x minutes xx.x seconds' formatted string" do
28
- expect(helper.format_duration(135.14)).to eq("2 minutes 15.1 seconds")
29
- end
30
- end
31
-
32
- context '> 300' do
33
- it "returns 'x minutes xx seconds' formatted string" do
34
- expect(helper.format_duration(335.14)).to eq("5 minutes 35 seconds")
35
- end
36
- end
37
-
38
- context '= 61' do
39
- it "returns 'x minute x second' formatted string" do
40
- expect(helper.format_duration(61)).to eq("1 minute 1 second")
41
- end
42
- end
43
-
44
- context '= 1' do
45
- it "returns 'x second' formatted string" do
46
- expect(helper.format_duration(1)).to eq("1 second")
47
- end
48
- end
49
-
50
- context 'with mathn loaded' do
51
- include MathnIntegrationSupport
52
-
53
- it "returns 'x minutes xx.x seconds' formatted string" do
54
- with_mathn_loaded do
55
- expect(helper.format_duration(133.7)).to eq("2 minutes 13.7 seconds")
56
- end
57
- end
58
- end
59
- end
60
-
61
- describe "format seconds" do
62
- it "uses passed in precision if specified unless result is 0" do
63
- expect(helper.format_seconds(0.01234, 2)).to eq("0.01")
64
- end
65
-
66
- context "sub second times" do
67
- it "returns 5 digits of precision" do
68
- expect(helper.format_seconds(0.000006)).to eq("0.00001")
69
- end
70
-
71
- it "strips off trailing zeroes beyond sub-second precision" do
72
- expect(helper.format_seconds(0.020000)).to eq("0.02")
73
- end
74
-
75
- context "0" do
76
- it "strips off trailing zeroes" do
77
- expect(helper.format_seconds(0.00000000001)).to eq("0")
78
- end
79
- end
80
-
81
- context "> 1" do
82
- it "strips off trailing zeroes" do
83
- expect(helper.format_seconds(1.00000000001)).to eq("1")
84
- end
85
- end
86
- end
87
-
88
- context "second and greater times" do
89
-
90
- it "returns 2 digits of precision" do
91
- expect(helper.format_seconds(50.330340)).to eq("50.33")
92
- end
93
-
94
- it "returns human friendly elasped time" do
95
- expect(helper.format_seconds(50.1)).to eq("50.1")
96
- expect(helper.format_seconds(5)).to eq("5")
97
- expect(helper.format_seconds(5.0)).to eq("5")
98
- end
99
-
100
- end
101
- end
102
-
103
-
104
- end