rspec-core 3.0.0.beta2 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.yardopts +1 -0
  5. data/Changelog.md +297 -57
  6. data/README.md +16 -13
  7. data/lib/rspec/core.rb +55 -84
  8. data/lib/rspec/core/backport_random.rb +35 -3
  9. data/lib/rspec/core/backtrace_formatter.rb +4 -13
  10. data/lib/rspec/core/configuration.rb +330 -114
  11. data/lib/rspec/core/configuration_options.rb +38 -22
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +8 -2
  14. data/lib/rspec/core/example.rb +203 -94
  15. data/lib/rspec/core/example_group.rb +344 -316
  16. data/lib/rspec/core/filter_manager.rb +135 -90
  17. data/lib/rspec/core/flat_map.rb +1 -0
  18. data/lib/rspec/core/formatters.rb +50 -14
  19. data/lib/rspec/core/formatters/base_formatter.rb +32 -138
  20. data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
  21. data/lib/rspec/core/formatters/console_codes.rb +65 -0
  22. data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
  23. data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
  24. data/lib/rspec/core/formatters/helpers.rb +15 -9
  25. data/lib/rspec/core/formatters/html_formatter.rb +17 -16
  26. data/lib/rspec/core/formatters/html_printer.rb +1 -0
  27. data/lib/rspec/core/formatters/json_formatter.rb +18 -20
  28. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  29. data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
  30. data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
  31. data/lib/rspec/core/hooks.rb +131 -125
  32. data/lib/rspec/core/memoized_helpers.rb +31 -26
  33. data/lib/rspec/core/metadata.rb +277 -184
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
  36. data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
  37. data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
  38. data/lib/rspec/core/mocking_adapters/null.rb +1 -1
  39. data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
  40. data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
  41. data/lib/rspec/core/notifications.rb +435 -24
  42. data/lib/rspec/core/option_parser.rb +16 -25
  43. data/lib/rspec/core/ordering.rb +3 -1
  44. data/lib/rspec/core/pending.rb +57 -33
  45. data/lib/rspec/core/project_initializer.rb +2 -0
  46. data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
  47. data/lib/rspec/core/rake_task.rb +45 -20
  48. data/lib/rspec/core/reporter.rb +50 -22
  49. data/lib/rspec/core/ruby_project.rb +1 -0
  50. data/lib/rspec/core/runner.rb +93 -39
  51. data/lib/rspec/core/shared_context.rb +7 -5
  52. data/lib/rspec/core/shared_example_group.rb +85 -77
  53. data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  54. data/lib/rspec/core/version.rb +3 -1
  55. data/lib/rspec/core/warnings.rb +35 -17
  56. data/lib/rspec/core/world.rb +57 -5
  57. metadata +56 -369
  58. metadata.gz.sig +3 -3
  59. data/features/README.md +0 -13
  60. data/features/Upgrade.md +0 -352
  61. data/features/command_line/README.md +0 -25
  62. data/features/command_line/dry_run.feature +0 -29
  63. data/features/command_line/example_name_option.feature +0 -97
  64. data/features/command_line/exit_status.feature +0 -82
  65. data/features/command_line/fail_fast.feature +0 -26
  66. data/features/command_line/format_option.feature +0 -75
  67. data/features/command_line/init.feature +0 -57
  68. data/features/command_line/line_number_appended_to_path.feature +0 -140
  69. data/features/command_line/line_number_option.feature +0 -58
  70. data/features/command_line/order.feature +0 -25
  71. data/features/command_line/pattern_option.feature +0 -49
  72. data/features/command_line/rake_task.feature +0 -122
  73. data/features/command_line/randomization.feature +0 -63
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -23
  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 -39
  79. data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
  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/enable_global_dsl.feature +0 -54
  84. data/features/configuration/fail_fast.feature +0 -77
  85. data/features/configuration/failure_exit_code.feature +0 -36
  86. data/features/configuration/order_and_seed.feature +0 -3
  87. data/features/configuration/output_stream.feature +0 -24
  88. data/features/configuration/overriding_global_ordering.feature +0 -93
  89. data/features/configuration/pattern.feature +0 -38
  90. data/features/configuration/profile.feature +0 -220
  91. data/features/configuration/read_options_from_file.feature +0 -90
  92. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  93. data/features/example_groups/aliasing.feature +0 -48
  94. data/features/example_groups/basic_structure.feature +0 -55
  95. data/features/example_groups/shared_context.feature +0 -74
  96. data/features/example_groups/shared_examples.feature +0 -286
  97. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
  98. data/features/filtering/exclusion_filters.feature +0 -135
  99. data/features/filtering/if_and_unless.feature +0 -138
  100. data/features/filtering/inclusion_filters.feature +0 -101
  101. data/features/formatters/configurable_colors.feature +0 -31
  102. data/features/formatters/custom_formatter.feature +0 -68
  103. data/features/formatters/json_formatter.feature +0 -30
  104. data/features/formatters/regression_tests.feature +0 -95
  105. data/features/formatters/text_formatter.feature +0 -46
  106. data/features/helper_methods/arbitrary_methods.feature +0 -40
  107. data/features/helper_methods/let.feature +0 -50
  108. data/features/helper_methods/modules.feature +0 -146
  109. data/features/hooks/around_hooks.feature +0 -344
  110. data/features/hooks/before_and_after_hooks.feature +0 -427
  111. data/features/hooks/filtering.feature +0 -232
  112. data/features/metadata/current_example.feature +0 -56
  113. data/features/metadata/described_class.feature +0 -17
  114. data/features/metadata/user_defined.feature +0 -100
  115. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  116. data/features/mock_framework_integration/use_flexmock.feature +0 -94
  117. data/features/mock_framework_integration/use_mocha.feature +0 -95
  118. data/features/mock_framework_integration/use_rr.feature +0 -96
  119. data/features/mock_framework_integration/use_rspec.feature +0 -95
  120. data/features/pending_and_skipped_examples/README.md +0 -3
  121. data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
  122. data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
  123. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  124. data/features/step_definitions/additional_cli_steps.rb +0 -83
  125. data/features/subject/explicit_subject.feature +0 -101
  126. data/features/subject/implicit_subject.feature +0 -63
  127. data/features/subject/one_liner_syntax.feature +0 -71
  128. data/features/support/env.rb +0 -21
  129. data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
  130. data/features/support/rubinius.rb +0 -6
  131. data/lib/rspec/core/command_line.rb +0 -35
  132. data/lib/rspec/core/drb_command_line.rb +0 -26
  133. data/lib/rspec/core/drb_options.rb +0 -87
  134. data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
  135. data/lib/rspec/core/shared_example_group/collection.rb +0 -27
  136. data/spec/command_line/order_spec.rb +0 -211
  137. data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
  138. data/spec/rspec/core/command_line_spec.rb +0 -112
  139. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  140. data/spec/rspec/core/configuration_options_spec.rb +0 -409
  141. data/spec/rspec/core/configuration_spec.rb +0 -1479
  142. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  143. data/spec/rspec/core/drb_options_spec.rb +0 -193
  144. data/spec/rspec/core/dsl_spec.rb +0 -88
  145. data/spec/rspec/core/example_group_spec.rb +0 -1533
  146. data/spec/rspec/core/example_spec.rb +0 -642
  147. data/spec/rspec/core/filter_manager_spec.rb +0 -229
  148. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
  149. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
  150. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
  151. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
  152. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  153. data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
  154. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  155. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
  156. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
  157. data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
  158. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
  159. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  160. data/spec/rspec/core/formatters_spec.rb +0 -120
  161. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  162. data/spec/rspec/core/hooks_spec.rb +0 -294
  163. data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
  164. data/spec/rspec/core/metadata_spec.rb +0 -491
  165. data/spec/rspec/core/option_parser_spec.rb +0 -262
  166. data/spec/rspec/core/ordering_spec.rb +0 -102
  167. data/spec/rspec/core/pending_example_spec.rb +0 -117
  168. data/spec/rspec/core/pending_spec.rb +0 -8
  169. data/spec/rspec/core/project_initializer_spec.rb +0 -73
  170. data/spec/rspec/core/rake_task_spec.rb +0 -146
  171. data/spec/rspec/core/random_spec.rb +0 -47
  172. data/spec/rspec/core/reporter_spec.rb +0 -155
  173. data/spec/rspec/core/resources/a_bar.rb +0 -0
  174. data/spec/rspec/core/resources/a_foo.rb +0 -0
  175. data/spec/rspec/core/resources/a_spec.rb +0 -1
  176. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  177. data/spec/rspec/core/resources/formatter_specs.rb +0 -58
  178. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  179. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  180. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  181. data/spec/rspec/core/runner_spec.rb +0 -151
  182. data/spec/rspec/core/shared_context_spec.rb +0 -102
  183. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
  184. data/spec/rspec/core/shared_example_group_spec.rb +0 -114
  185. data/spec/rspec/core/warnings_spec.rb +0 -29
  186. data/spec/rspec/core/world_spec.rb +0 -142
  187. data/spec/rspec/core_spec.rb +0 -91
  188. data/spec/spec_helper.rb +0 -160
  189. data/spec/support/config_options_helper.rb +0 -13
  190. data/spec/support/formatter_support.rb +0 -83
  191. data/spec/support/helper_methods.rb +0 -26
  192. data/spec/support/isolate_load_path_mutation.rb +0 -5
  193. data/spec/support/isolated_directory.rb +0 -10
  194. data/spec/support/isolated_home_directory.rb +0 -16
  195. data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
  196. data/spec/support/matchers.rb +0 -85
  197. data/spec/support/mathn_integration_support.rb +0 -12
  198. data/spec/support/old_style_formatter_example.rb +0 -69
  199. data/spec/support/shared_example_groups.rb +0 -13
  200. data/spec/support/spec_files.rb +0 -44
  201. data/spec/support/stderr_splitter.rb +0 -36
@@ -1,208 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/reporter'
3
- require 'rspec/core/formatters/deprecation_formatter'
4
- require 'tempfile'
5
-
6
- module RSpec::Core::Formatters
7
- RSpec.describe DeprecationFormatter do
8
- include FormatterSupport
9
-
10
- let(:summary_stream) { StringIO.new }
11
-
12
- def notification(hash)
13
- ::RSpec::Core::Notifications::DeprecationNotification.from_hash(hash)
14
- end
15
-
16
- before do
17
- setup_reporter deprecation_stream, summary_stream
18
- end
19
-
20
- describe "#deprecation" do
21
-
22
- context "with a File deprecation_stream", :slow do
23
- let(:deprecation_stream) { File.open("#{Dir.tmpdir}/deprecation_summary_example_output", "w+") }
24
-
25
- it "prints a message if provided, ignoring other data" do
26
- send_notification :deprecation, notification(:message => "this message", :deprecated => "x", :replacement => "y", :call_site => "z")
27
- deprecation_stream.rewind
28
- expect(deprecation_stream.read).to eq "this message\n"
29
- end
30
-
31
- it "includes the method" do
32
- send_notification :deprecation, notification(:deprecated => "i_am_deprecated")
33
- deprecation_stream.rewind
34
- expect(deprecation_stream.read).to match(/i_am_deprecated is deprecated/)
35
- end
36
-
37
- it "includes the replacement" do
38
- send_notification :deprecation, notification(:replacement => "use_me")
39
- deprecation_stream.rewind
40
- expect(deprecation_stream.read).to match(/Use use_me instead/)
41
- end
42
-
43
- it "includes the call site if provided" do
44
- send_notification :deprecation, notification(:call_site => "somewhere")
45
- deprecation_stream.rewind
46
- expect(deprecation_stream.read).to match(/Called from somewhere/)
47
- end
48
- end
49
-
50
- context "with an IO deprecation stream" do
51
- let(:deprecation_stream) { StringIO.new }
52
-
53
- it "prints nothing" do
54
- 5.times { send_notification :deprecation, notification(:deprecated => 'i_am_deprecated') }
55
- expect(deprecation_stream.string).to eq ""
56
- end
57
- end
58
- end
59
-
60
- describe "#deprecation_summary" do
61
- let(:summary) { double }
62
-
63
- context "with a File deprecation_stream", :slow do
64
- let(:deprecation_stream) { File.open("#{Dir.tmpdir}/deprecation_summary_example_output", "w") }
65
-
66
- it "prints a count of the deprecations" do
67
- send_notification :deprecation, notification(:deprecated => 'i_am_deprecated')
68
- send_notification :deprecation_summary, null_notification
69
- expect(summary_stream.string).to match(/1 deprecation logged to .*deprecation_summary_example_output/)
70
- end
71
-
72
- it "pluralizes the reported deprecation count for more than one deprecation" do
73
- send_notification :deprecation, notification(:deprecated => 'i_am_deprecated')
74
- send_notification :deprecation, notification(:deprecated => 'i_am_deprecated_also')
75
- send_notification :deprecation_summary, null_notification
76
- expect(summary_stream.string).to match(/2 deprecations/)
77
- end
78
-
79
- it "is not printed when there are no deprecations" do
80
- send_notification :deprecation_summary, null_notification
81
- expect(summary_stream.string).to eq ""
82
- end
83
-
84
- it 'uses synchronized/non-buffered output to work around odd duplicate output behavior we have observed' do
85
- expect {
86
- send_notification :deprecation, notification(:deprecated => 'foo')
87
- }.to change { deprecation_stream.sync }.from(false).to(true)
88
- end
89
-
90
- it 'does not print duplicate messages' do
91
- 3.times { send_notification :deprecation, notification(:deprecated => 'foo') }
92
- send_notification :deprecation_summary, null_notification
93
-
94
- expect(summary_stream.string).to match(/1 deprecation/)
95
- expect(File.read(deprecation_stream.path)).to eq("foo is deprecated.\n#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}")
96
- end
97
- end
98
-
99
- context "with an Error deprecation_stream" do
100
- let(:deprecation_stream) { DeprecationFormatter::RaiseErrorStream.new }
101
-
102
- it 'prints a summary of the number of deprecations found' do
103
- expect { send_notification :deprecation, notification(:deprecated => 'foo') }.to raise_error(RSpec::Core::DeprecationError)
104
- send_notification :deprecation_summary, null_notification
105
-
106
- expect(summary_stream.string).to eq("\n1 deprecation found.\n")
107
- end
108
-
109
- it 'pluralizes the count when it is greater than 1' do
110
- expect { send_notification :deprecation, notification(:deprecated => 'foo') }.to raise_error(RSpec::Core::DeprecationError)
111
- expect { send_notification :deprecation, notification(:deprecated => 'bar') }.to raise_error(RSpec::Core::DeprecationError)
112
-
113
- send_notification :deprecation_summary, null_notification
114
-
115
- expect(summary_stream.string).to eq("\n2 deprecations found.\n")
116
- end
117
- end
118
-
119
- context "with an IO deprecation_stream" do
120
- let(:deprecation_stream) { StringIO.new }
121
-
122
- it "groups similar deprecations together" do
123
- send_notification :deprecation, notification(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:1")
124
- send_notification :deprecation, notification(:deprecated => 'i_am_a_different_deprecation')
125
- send_notification :deprecation, notification(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:2")
126
- send_notification :deprecation_summary, null_notification
127
-
128
- expected = <<-EOS.gsub(/^\s+\|/, '')
129
- |
130
- |Deprecation Warnings:
131
- |
132
- |i_am_a_different_deprecation is deprecated.
133
- |
134
- |i_am_deprecated is deprecated. Called from foo.rb:1.
135
- |i_am_deprecated is deprecated. Called from foo.rb:2.
136
- |
137
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
138
- EOS
139
- expect(deprecation_stream.string).to eq expected.chomp
140
- end
141
-
142
- it "limits the deprecation warnings after 3 calls" do
143
- 5.times { |i| send_notification :deprecation, notification(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:#{i + 1}") }
144
- send_notification :deprecation_summary, null_notification
145
- expected = <<-EOS.gsub(/^\s+\|/, '')
146
- |
147
- |Deprecation Warnings:
148
- |
149
- |i_am_deprecated is deprecated. Called from foo.rb:1.
150
- |i_am_deprecated is deprecated. Called from foo.rb:2.
151
- |i_am_deprecated is deprecated. Called from foo.rb:3.
152
- |Too many uses of deprecated 'i_am_deprecated'. Set config.deprecation_stream to a File for full output.
153
- |
154
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
155
- EOS
156
- expect(deprecation_stream.string).to eq expected.chomp
157
- end
158
-
159
- it "limits :message deprecation warnings with different callsites after 3 calls" do
160
- 5.times do |n|
161
- 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."
162
- send_notification :deprecation, notification(:message => message)
163
- end
164
- send_notification :deprecation_summary, null_notification
165
- expected = <<-EOS.gsub(/^\s+\|/, '')
166
- |
167
- |Deprecation Warnings:
168
- |
169
- |This is a long string with some callsite info: /path/0/to/some/file.rb:203. And some more stuff can come after.
170
- |This is a long string with some callsite info: /path/1/to/some/file.rb:213. And some more stuff can come after.
171
- |This is a long string with some callsite info: /path/2/to/some/file.rb:223. And some more stuff can come after.
172
- |Too many similar deprecation messages reported, disregarding further reports. Set config.deprecation_stream to a File for full output.
173
- |
174
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
175
- EOS
176
- expect(deprecation_stream.string).to eq expected.chomp
177
- end
178
-
179
- it "prints the true deprecation count to the summary_stream" do
180
- 5.times { |i| send_notification :deprecation, notification(:deprecated => 'i_am_deprecated', :call_site => "foo.rb:#{i + 1}") }
181
- 5.times do |n|
182
- send_notification :deprecation, notification(:message => "callsite info: /path/#{n}/to/some/file.rb:2#{n}3. And some more stuff")
183
- end
184
- send_notification :deprecation_summary, null_notification
185
- expect(summary_stream.string).to match(/10 deprecation warnings total/)
186
- end
187
-
188
- it 'does not print duplicate messages' do
189
- 3.times { send_notification :deprecation, notification(:deprecated => 'foo') }
190
- send_notification :deprecation_summary, null_notification
191
-
192
- expect(summary_stream.string).to match(/1 deprecation/)
193
-
194
- expected = <<-EOS.gsub(/^\s+\|/, '')
195
- |
196
- |Deprecation Warnings:
197
- |
198
- |foo is deprecated.
199
- |
200
- |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
201
- EOS
202
-
203
- expect(deprecation_stream.string).to eq expected.chomp
204
- end
205
- end
206
- end
207
- end
208
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/documentation_formatter'
3
-
4
- module RSpec::Core::Formatters
5
- RSpec.describe DocumentationFormatter do
6
- include FormatterSupport
7
-
8
- before do
9
- send_notification :start, count_notification(2)
10
- allow(formatter).to receive(:color_enabled?).and_return(false)
11
- end
12
-
13
- it "numbers the failures" do
14
- send_notification :example_failed, example_notification( double("example 1",
15
- :description => "first example",
16
- :execution_result => {:status => 'failed', :exception => Exception.new }
17
- ))
18
- send_notification :example_failed, example_notification( double("example 2",
19
- :description => "second example",
20
- :execution_result => {:status => 'failed', :exception => Exception.new }
21
- ))
22
-
23
- expect(output.string).to match(/first example \(FAILED - 1\)/m)
24
- expect(output.string).to match(/second example \(FAILED - 2\)/m)
25
- end
26
-
27
- it "represents nested group using hierarchy tree" do
28
- group = RSpec::Core::ExampleGroup.describe("root")
29
- context1 = group.describe("context 1")
30
- context1.example("nested example 1.1"){}
31
- context1.example("nested example 1.2"){}
32
-
33
- context11 = context1.describe("context 1.1")
34
- context11.example("nested example 1.1.1"){}
35
- context11.example("nested example 1.1.2"){}
36
-
37
- context2 = group.describe("context 2")
38
- context2.example("nested example 2.1"){}
39
- context2.example("nested example 2.2"){}
40
-
41
- group.run(reporter)
42
-
43
- expect(output.string).to eql("
44
- root
45
- context 1
46
- nested example 1.1
47
- nested example 1.2
48
- context 1.1
49
- nested example 1.1.1
50
- nested example 1.1.2
51
- context 2
52
- nested example 2.1
53
- nested example 2.2
54
- ")
55
- end
56
-
57
- it "strips whitespace for each row" do
58
- group = RSpec::Core::ExampleGroup.describe(" root ")
59
- context1 = group.describe(" nested ")
60
- context1.example(" example 1 ") {}
61
- context1.example(" example 2 ", :pending => true){ fail }
62
- context1.example(" example 3 ") { fail }
63
-
64
- group.run(reporter)
65
-
66
- expect(output.string).to eql("
67
- root
68
- nested
69
- example 1
70
- example 2 (PENDING: No reason given)
71
- example 3 (FAILED - 1)
72
- ")
73
- end
74
- end
75
- end
@@ -1,104 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/helpers'
3
-
4
- RSpec.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", :slow 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
@@ -1,392 +0,0 @@
1
- <html lang="en">
2
- <head>
3
- <title>RSpec results</title>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta http-equiv="Expires" content="-1">
6
- <meta http-equiv="Pragma" content="no-cache">
7
- <style type="text/css">
8
- body {
9
- margin: 0;
10
- padding: 0;
11
- background: #fff;
12
- font-size: 80%;
13
- }
14
- </style>
15
- <script type="text/javascript">
16
- // <![CDATA[
17
-
18
- function addClass(element_id, classname) {
19
- document.getElementById(element_id).className += (" " + classname);
20
- }
21
-
22
- function removeClass(element_id, classname) {
23
- var elem = document.getElementById(element_id);
24
- var classlist = elem.className.replace(classname,'');
25
- elem.className = classlist;
26
- }
27
-
28
- function moveProgressBar(percentDone) {
29
- document.getElementById("rspec-header").style.width = percentDone +"%";
30
- }
31
-
32
- function makeRed(element_id) {
33
- removeClass(element_id, 'passed');
34
- removeClass(element_id, 'not_implemented');
35
- addClass(element_id,'failed');
36
- }
37
-
38
- function makeYellow(element_id) {
39
- var elem = document.getElementById(element_id);
40
- if (elem.className.indexOf("failed") == -1) { // class doesn't includes failed
41
- if (elem.className.indexOf("not_implemented") == -1) { // class doesn't include not_implemented
42
- removeClass(element_id, 'passed');
43
- addClass(element_id,'not_implemented');
44
- }
45
- }
46
- }
47
-
48
- function apply_filters() {
49
- var passed_filter = document.getElementById('passed_checkbox').checked;
50
- var failed_filter = document.getElementById('failed_checkbox').checked;
51
- var pending_filter = document.getElementById('pending_checkbox').checked;
52
-
53
- assign_display_style("example passed", passed_filter);
54
- assign_display_style("example failed", failed_filter);
55
- assign_display_style("example not_implemented", pending_filter);
56
-
57
- assign_display_style_for_group("example_group passed", passed_filter);
58
- assign_display_style_for_group("example_group not_implemented", pending_filter, pending_filter || passed_filter);
59
- assign_display_style_for_group("example_group failed", failed_filter, failed_filter || pending_filter || passed_filter);
60
- }
61
-
62
- function get_display_style(display_flag) {
63
- var style_mode = 'none';
64
- if (display_flag == true) {
65
- style_mode = 'block';
66
- }
67
- return style_mode;
68
- }
69
-
70
- function assign_display_style(classname, display_flag) {
71
- var style_mode = get_display_style(display_flag);
72
- var elems = document.getElementsByClassName(classname)
73
- for (var i=0; i<elems.length;i++) {
74
- elems[i].style.display = style_mode;
75
- }
76
- }
77
-
78
- function assign_display_style_for_group(classname, display_flag, subgroup_flag) {
79
- var display_style_mode = get_display_style(display_flag);
80
- var subgroup_style_mode = get_display_style(subgroup_flag);
81
- var elems = document.getElementsByClassName(classname)
82
- for (var i=0; i<elems.length;i++) {
83
- var style_mode = display_style_mode;
84
- if ((display_flag != subgroup_flag) && (elems[i].getElementsByTagName('dt')[0].innerHTML.indexOf(", ") != -1)) {
85
- elems[i].style.display = subgroup_style_mode;
86
- } else {
87
- elems[i].style.display = display_style_mode;
88
- }
89
- }
90
- }
91
-
92
- // ]]>
93
- </script>
94
- <style type="text/css">
95
- #rspec-header {
96
- background: #65C400; color: #fff; height: 4em;
97
- }
98
-
99
- .rspec-report h1 {
100
- margin: 0px 10px 0px 10px;
101
- padding: 10px;
102
- font-family: "Lucida Grande", Helvetica, sans-serif;
103
- font-size: 1.8em;
104
- position: absolute;
105
- }
106
-
107
- #label {
108
- float:left;
109
- }
110
-
111
- #display-filters {
112
- float:left;
113
- padding: 28px 0 0 40%;
114
- font-family: "Lucida Grande", Helvetica, sans-serif;
115
- }
116
-
117
- #summary {
118
- float:right;
119
- padding: 5px 10px;
120
- font-family: "Lucida Grande", Helvetica, sans-serif;
121
- text-align: right;
122
- }
123
-
124
- #summary p {
125
- margin: 0 0 0 2px;
126
- }
127
-
128
- #summary #totals {
129
- font-size: 1.2em;
130
- }
131
-
132
- .example_group {
133
- margin: 0 10px 5px;
134
- background: #fff;
135
- }
136
-
137
- dl {
138
- margin: 0; padding: 0 0 5px;
139
- font: normal 11px "Lucida Grande", Helvetica, sans-serif;
140
- }
141
-
142
- dt {
143
- padding: 3px;
144
- background: #65C400;
145
- color: #fff;
146
- font-weight: bold;
147
- }
148
-
149
- dd {
150
- margin: 5px 0 5px 5px;
151
- padding: 3px 3px 3px 18px;
152
- }
153
-
154
- dd .duration {
155
- padding-left: 5px;
156
- text-align: right;
157
- right: 0px;
158
- float:right;
159
- }
160
-
161
- dd.example.passed {
162
- border-left: 5px solid #65C400;
163
- border-bottom: 1px solid #65C400;
164
- background: #DBFFB4; color: #3D7700;
165
- }
166
-
167
- dd.example.not_implemented {
168
- border-left: 5px solid #FAF834;
169
- border-bottom: 1px solid #FAF834;
170
- background: #FCFB98; color: #131313;
171
- }
172
-
173
- dd.example.pending_fixed {
174
- border-left: 5px solid #0000C2;
175
- border-bottom: 1px solid #0000C2;
176
- color: #0000C2; background: #D3FBFF;
177
- }
178
-
179
- dd.example.failed {
180
- border-left: 5px solid #C20000;
181
- border-bottom: 1px solid #C20000;
182
- color: #C20000; background: #FFFBD3;
183
- }
184
-
185
-
186
- dt.not_implemented {
187
- color: #000000; background: #FAF834;
188
- }
189
-
190
- dt.pending_fixed {
191
- color: #FFFFFF; background: #C40D0D;
192
- }
193
-
194
- dt.failed {
195
- color: #FFFFFF; background: #C40D0D;
196
- }
197
-
198
-
199
- #rspec-header.not_implemented {
200
- color: #000000; background: #FAF834;
201
- }
202
-
203
- #rspec-header.pending_fixed {
204
- color: #FFFFFF; background: #C40D0D;
205
- }
206
-
207
- #rspec-header.failed {
208
- color: #FFFFFF; background: #C40D0D;
209
- }
210
-
211
-
212
- .backtrace {
213
- color: #000;
214
- font-size: 12px;
215
- }
216
-
217
- a {
218
- color: #BE5C00;
219
- }
220
-
221
- /* Ruby code, style similar to vibrant ink */
222
- .ruby {
223
- font-size: 12px;
224
- font-family: monospace;
225
- color: white;
226
- background-color: black;
227
- padding: 0.1em 0 0.2em 0;
228
- }
229
-
230
- .ruby .keyword { color: #FF6600; }
231
- .ruby .constant { color: #339999; }
232
- .ruby .attribute { color: white; }
233
- .ruby .global { color: white; }
234
- .ruby .module { color: white; }
235
- .ruby .class { color: white; }
236
- .ruby .string { color: #66FF00; }
237
- .ruby .ident { color: white; }
238
- .ruby .method { color: #FFCC00; }
239
- .ruby .number { color: white; }
240
- .ruby .char { color: white; }
241
- .ruby .comment { color: #9933CC; }
242
- .ruby .symbol { color: white; }
243
- .ruby .regex { color: #44B4CC; }
244
- .ruby .punct { color: white; }
245
- .ruby .escape { color: white; }
246
- .ruby .interp { color: white; }
247
- .ruby .expr { color: white; }
248
-
249
- .ruby .offending { background-color: gray; }
250
- .ruby .linenum {
251
- width: 75px;
252
- padding: 0.1em 1em 0.2em 0;
253
- color: #000000;
254
- background-color: #FFFBD3;
255
- }
256
-
257
- </style>
258
- </head>
259
- <body>
260
- <div class="rspec-report">
261
-
262
- <div id="rspec-header">
263
- <div id="label">
264
- <h1>RSpec Code Examples</h1>
265
- </div>
266
-
267
- <div id="display-filters">
268
- <input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked onchange="apply_filters()" value="1"> <label for="passed_checkbox">Passed</label>
269
- <input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked onchange="apply_filters()" value="2"> <label for="failed_checkbox">Failed</label>
270
- <input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked onchange="apply_filters()" value="3"> <label for="pending_checkbox">Pending</label>
271
- </div>
272
-
273
- <div id="summary">
274
- <p id="totals"> </p>
275
- <p id="duration"> </p>
276
- </div>
277
- </div>
278
-
279
-
280
- <div class="results">
281
- <div id="div_group_1" class="example_group passed">
282
- <dl style="margin-left: 0px;">
283
- <dt id="example_group_1" class="passed">pending spec with no implementation</dt>
284
- <script type="text/javascript">makeYellow('rspec-header');</script>
285
- <script type="text/javascript">makeYellow('div_group_1');</script>
286
- <script type="text/javascript">makeYellow('example_group_1');</script>
287
- <script type="text/javascript">moveProgressBar('14.2');</script>
288
- <dd class="example not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: Not yet implemented)</span></dd>
289
- </dl>
290
- </div>
291
- <div id="div_group_2" class="example_group passed">
292
- <dl style="margin-left: 0px;">
293
- <dt id="example_group_2" class="passed">pending command with block format</dt>
294
- </dl>
295
- </div>
296
- <div id="div_group_3" class="example_group passed">
297
- <dl style="margin-left: 15px;">
298
- <dt id="example_group_3" class="passed">with content that would fail</dt>
299
- <script type="text/javascript">moveProgressBar('28.5');</script>
300
- <dd class="example passed"><span class="passed_spec_name">is pending</span><span class='duration'>n.nnnns</span></dd>
301
- </dl>
302
- </div>
303
- <div id="div_group_4" class="example_group passed">
304
- <dl style="margin-left: 15px;">
305
- <dt id="example_group_4" class="passed">with content that would pass</dt>
306
- <script type="text/javascript">makeRed('rspec-header');</script>
307
- <script type="text/javascript">makeRed('div_group_4');</script>
308
- <script type="text/javascript">makeRed('example_group_4');</script>
309
- <script type="text/javascript">moveProgressBar('42.8');</script>
310
- <dd class="example pending_fixed">
311
- <span class="failed_spec_name">fails</span>
312
- <span class="duration">n.nnnns</span>
313
- <div class="failure" id="failure_1">
314
- <div class="message"><pre>RSpec::Core::Pending::PendingExampleFixedError</pre></div>
315
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:18</pre></div>
316
- <pre class="ruby"><code><span class="linenum">16</span> context <span class="string"><span class="delimiter">"</span><span class="content">with content that would pass</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
317
- <span class="linenum">17</span> it <span class="string"><span class="delimiter">"</span><span class="content">fails</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
318
- <span class="offending"><span class="linenum">18</span> pending <span class="keyword">do</span></span>
319
- <span class="linenum">19</span> expect(<span class="integer">1</span>).to eq(<span class="integer">1</span>)
320
- <span class="linenum">20</span> <span class="keyword">end</span></code></pre>
321
- </div>
322
- </dd>
323
- </dl>
324
- </div>
325
- <div id="div_group_5" class="example_group passed">
326
- <dl style="margin-left: 0px;">
327
- <dt id="example_group_5" class="passed">passing spec</dt>
328
- <script type="text/javascript">moveProgressBar('57.1');</script>
329
- <dd class="example passed">
330
- <span class="passed_spec_name">passes</span><span class="duration">n.nnnns</span>
331
- </dd>
332
- </dl>
333
- </div>
334
- <div id="div_group_6" class="example_group passed">
335
- <dl style="margin-left: 0px;">
336
- <dt id="example_group_6" class="passed">failing spec</dt>
337
- <script type="text/javascript">makeRed('div_group_6');</script>
338
- <script type="text/javascript">makeRed('example_group_6');</script>
339
- <script type="text/javascript">moveProgressBar('71.4');</script>
340
- <dd class="example failed">
341
- <span class="failed_spec_name">fails</span>
342
- <span class="duration">n.nnnns</span>
343
- <div class="failure" id="failure_2">
344
- <div class="message"><pre>
345
- expected: 2
346
- got: 1
347
-
348
- (compared using ==)
349
- </pre></div>
350
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33</pre></div>
351
- <pre class="ruby"><code><span class="linenum">31</span><span class="constant">RSpec</span>.describe <span class="string"><span class="delimiter">"</span><span class="content">failing spec</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
352
- <span class="linenum">32</span> it <span class="string"><span class="delimiter">"</span><span class="content">fails</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
353
- <span class="offending"><span class="linenum">33</span> expect(<span class="integer">1</span>).to eq(<span class="integer">2</span>)</span>
354
- <span class="linenum">34</span> <span class="keyword">end</span>
355
- <span class="linenum">35</span><span class="keyword">end</span></code></pre>
356
- </div>
357
- </dd>
358
- </dl>
359
- </div>
360
- <div id="div_group_7" class="example_group passed">
361
- <dl style="margin-left: 0px;">
362
- <dt id="example_group_7" class="passed">a failing spec with odd backtraces</dt>
363
- <script type="text/javascript">makeRed('div_group_7');</script>
364
- <script type="text/javascript">makeRed('example_group_7');</script>
365
- <script type="text/javascript">moveProgressBar('85.7');</script>
366
- <dd class="example failed">
367
- <span class="failed_spec_name">fails with a backtrace that has no file</span>
368
- <span class="duration">n.nnnns</span>
369
- <div class="failure" id="failure_3">
370
- <div class="message"><pre>foo</pre></div>
371
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:41</pre></div>
372
- <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
373
- </div>
374
- </dd>
375
- <script type="text/javascript">moveProgressBar('100.0');</script>
376
- <dd class="example failed">
377
- <span class="failed_spec_name">fails with a backtrace containing an erb file</span>
378
- <span class="duration">n.nnnns</span>
379
- <div class="failure" id="failure_4">
380
- <div class="message"><pre>Exception</pre></div>
381
- <div class="backtrace"><pre></pre></div>
382
- <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
383
- </div>
384
- </dd>
385
- </dl>
386
- </div>
387
- <script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>n.nnnn seconds</strong>";</script>
388
- <script type="text/javascript">document.getElementById('totals').innerHTML = "7 examples, 4 failures, 1 pending";</script>
389
- </div>
390
- </div>
391
- </body>
392
- </html>