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,206 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/json_formatter'
3
- require 'json'
4
- require 'rspec/core/reporter'
5
-
6
- # todo, someday:
7
- # it "lists the groups (describe and context) separately"
8
- # it "includes full 'execution_result'"
9
- # it "relativizes backtrace paths"
10
- # it "includes profile information (implements dump_profile)"
11
- # it "shows the pending message if one was given"
12
- # it "shows the seed if run was randomized"
13
- # it "lists pending specs that were fixed"
14
- RSpec.describe RSpec::Core::Formatters::JsonFormatter do
15
- include FormatterSupport
16
-
17
- it "outputs json (brittle high level functional test)" do
18
- group = RSpec::Core::ExampleGroup.describe("one apiece") do
19
- it("succeeds") { expect(1).to eq 1 }
20
- it("fails") { fail "eek" }
21
- it("pends") { pending "world peace"; fail "eek" }
22
- end
23
- succeeding_line = __LINE__ - 4
24
- failing_line = __LINE__ - 4
25
- pending_line = __LINE__ - 4
26
-
27
- now = Time.now
28
- allow(Time).to receive(:now).and_return(now)
29
- reporter.report(2) do |r|
30
- group.run(r)
31
- end
32
-
33
- # grab the actual backtrace -- kind of a cheat
34
- examples = formatter.output_hash[:examples]
35
- failing_backtrace = examples[1][:exception][:backtrace]
36
- this_file = relative_path(__FILE__)
37
-
38
- expected = {
39
- :examples => [
40
- {
41
- :description => "succeeds",
42
- :full_description => "one apiece succeeds",
43
- :status => "passed",
44
- :file_path => this_file,
45
- :line_number => succeeding_line,
46
- :run_time => formatter.output_hash[:examples][0][:run_time]
47
- },
48
- {
49
- :description => "fails",
50
- :full_description => "one apiece fails",
51
- :status => "failed",
52
- :file_path => this_file,
53
- :line_number => failing_line,
54
- :run_time => formatter.output_hash[:examples][1][:run_time],
55
- :exception => {
56
- :class => "RuntimeError",
57
- :message => "eek",
58
- :backtrace => failing_backtrace
59
- }
60
- },
61
- {
62
- :description => "pends",
63
- :full_description => "one apiece pends",
64
- :status => "pending",
65
- :file_path => this_file,
66
- :line_number => pending_line,
67
- :run_time => formatter.output_hash[:examples][2][:run_time]
68
- },
69
- ],
70
- :summary => {
71
- :duration => formatter.output_hash[:summary][:duration],
72
- :example_count => 3,
73
- :failure_count => 1,
74
- :pending_count => 1,
75
- },
76
- :summary_line => "3 examples, 1 failure, 1 pending"
77
- }
78
- expect(formatter.output_hash).to eq expected
79
- expect(output.string).to eq expected.to_json
80
- end
81
-
82
- describe "#stop" do
83
- it "adds all examples to the output hash" do
84
- send_notification :stop, null_notification
85
- expect(formatter.output_hash[:examples]).not_to be_nil
86
- end
87
- end
88
-
89
- describe "#close" do
90
- it "outputs the results as a JSON string" do
91
- expect(output.string).to eq ""
92
- send_notification :close, null_notification
93
- expect(output.string).to eq("{}")
94
- end
95
- end
96
-
97
- describe "#message" do
98
- it "adds a message to the messages list" do
99
- send_notification :message, message_notification("good job")
100
- expect(formatter.output_hash[:messages]).to eq ["good job"]
101
- end
102
- end
103
-
104
- describe "#dump_summary" do
105
- it "adds summary info to the output hash" do
106
- send_notification :dump_summary, summary_notification(1.0, 10, 3, 4)
107
- expect(formatter.output_hash[:summary]).to include(
108
- :duration => 1.0, :example_count => 10, :failure_count => 3,
109
- :pending_count => 4
110
- )
111
- summary_line = formatter.output_hash[:summary_line]
112
- expect(summary_line).to eq "10 examples, 3 failures, 4 pending"
113
- end
114
- end
115
-
116
- describe "#dump_profile_slowest_examples", :slow do
117
-
118
- before do
119
- group = RSpec::Core::ExampleGroup.describe("group") do
120
- example("example") { }
121
- end
122
- group.run(reporter)
123
-
124
- allow(formatter).to receive(:examples) { group.examples }
125
- allow(RSpec.configuration).to receive(:profile_examples) { 10 }
126
- end
127
-
128
- it "names the example" do
129
- formatter.dump_profile_slowest_examples
130
- expect(formatter.output_hash[:profile][:examples].first[:full_description]).to eq("group example")
131
- end
132
-
133
- it "provides example execution time" do
134
- formatter.dump_profile_slowest_examples
135
- expect(formatter.output_hash[:profile][:examples].first[:run_time]).not_to be_nil
136
- end
137
-
138
- it "has the summary of profile information" do
139
- formatter.dump_profile_slowest_examples
140
- expect(formatter.output_hash[:profile].keys).to match_array([:examples, :slowest, :total])
141
- end
142
- end
143
-
144
- describe "#dump_profile_slowest_example_groups", :slow do
145
- let(:group) do
146
- RSpec::Core::ExampleGroup.describe("slow group") do
147
- example("example") do |example|
148
- # make it look slow without actually taking up precious time
149
- example.clock = class_double(RSpec::Core::Time, :now => RSpec::Core::Time.now + 0.5)
150
- end
151
- end
152
- end
153
-
154
- before do
155
- allow(RSpec.configuration).to receive(:profile_examples) { 10 }
156
- group.run(reporter)
157
- end
158
-
159
- context "with one example group" do
160
- before { allow(formatter).to receive(:examples) { group.examples } }
161
-
162
- it "doesn't profile a single example group" do
163
- formatter.dump_profile_slowest_example_groups
164
- expect(formatter.output_hash[:profile][:groups]).to be_empty
165
- end
166
- end
167
-
168
- context "with multiple example groups", :slow do
169
- before do
170
- group2 = RSpec::Core::ExampleGroup.describe("fast group") do
171
- example("example 1") { }
172
- example("example 2") { }
173
- end
174
- group2.run(reporter)
175
-
176
- allow(formatter).to receive(:examples) { group.examples + group2.examples }
177
- end
178
-
179
- it "provides the slowest example groups" do
180
- formatter.dump_profile_slowest_example_groups
181
- expect(formatter.output_hash).not_to be_empty
182
- end
183
-
184
- it "provides information" do
185
- formatter.dump_profile_slowest_example_groups
186
- expect(formatter.output_hash[:profile][:groups].first.keys).to match_array([:total_time, :count, :description, :average, :location])
187
- end
188
-
189
- it "ranks the example groups by average time" do
190
- formatter.dump_profile_slowest_example_groups
191
- expect(formatter.output_hash[:profile][:groups].first[:description]).to eq("slow group")
192
- end
193
- end
194
-
195
- it "depends on parent_groups to get the top level example group" do
196
- ex = ""
197
- group.describe("group 2") do
198
- describe "group 3" do
199
- ex = example("nested example 1")
200
- end
201
- end
202
-
203
- expect(ex.example_group.parent_groups.last).to eq(group)
204
- end
205
- end
206
- end
@@ -1,137 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/legacy_formatter'
3
- require 'support/old_style_formatter_example'
4
- require 'support/legacy_formatter_using_sub_classing_example'
5
-
6
- RSpec.describe RSpec::Core::Formatters::LegacyFormatter do
7
- include FormatterSupport
8
-
9
- it 'can access attributes provided by base class accessors in #initialize' do
10
- klass = Class.new(LegacyFormatterUsingSubClassing) do
11
- def initialize(*args)
12
- example_count
13
- super
14
- end
15
- end
16
-
17
- config.add_formatter klass
18
- expect(config.formatters.first).to be_a(RSpec::Core::Formatters::LegacyFormatter)
19
- expect(config.formatters.first.formatter).to be_a(klass)
20
- end
21
-
22
- [OldStyleFormatterExample, LegacyFormatterUsingSubClassing].each do |klass|
23
-
24
- describe "#{klass}" do
25
- let(:described_class) { klass }
26
-
27
- describe "#start" do
28
- it "notifies formatter of start" do
29
- send_notification :start, count_notification(5)
30
- expect(output.string).to include "Started 5 examples"
31
- end
32
- end
33
-
34
- describe "#example_group_started" do
35
- it "notifies formatter of example_group_started" do
36
- send_notification :example_group_started, group_notification
37
- expect(output.string).to include "Started Group"
38
- end
39
- end
40
-
41
- describe "#example_group_finished" do
42
- it "notifies formatter of example_group_finished" do
43
- send_notification :example_group_finished, group_notification
44
- expect(output.string).to include "Finished Group"
45
- end
46
- end
47
-
48
- describe "#example_started" do
49
- it "notifies formatter of example_started" do
50
- send_notification :example_started, example_notification
51
- expect(output.string).to include "Started Example"
52
- end
53
- end
54
-
55
- describe "#example_passed" do
56
- it "notifies formatter of example_passed" do
57
- send_notification :example_passed, example_notification
58
- expect(output.string).to include "."
59
- end
60
- end
61
-
62
- describe "#example_pending" do
63
- it "notifies formatter of example_pending" do
64
- send_notification :example_pending, example_notification
65
- expect(output.string).to include "P"
66
- end
67
- end
68
-
69
- describe "#example_failed" do
70
- it "notifies formatter of example_failed" do
71
- send_notification :example_failed, example_notification
72
- expect(output.string).to include "F"
73
- end
74
- end
75
-
76
- describe "#message" do
77
- it "notifies formatter of message" do
78
- send_notification :message, message_notification("A Message")
79
- expect(output.string).to include "A Message"
80
- end
81
- end
82
-
83
- describe "#stop" do
84
- it "notifies formatter of stop" do
85
- send_notification :stop, null_notification
86
- expect(output.string).to include "Stopped"
87
- end
88
- end
89
-
90
- describe "#start_dump" do
91
- it "notifies formatter of start_dump" do
92
- send_notification :start_dump, null_notification
93
- expect(output.string).to include "Dumping!"
94
- end
95
- end
96
-
97
- describe "#dump_failures" do
98
- it "notifies formatter of dump_failures" do
99
- send_notification :dump_failures, null_notification
100
- expect(output.string).to include "Failures:"
101
- end
102
- end
103
-
104
- describe "#dump_summary" do
105
- it "notifies formatter of dump_summary" do
106
- duration, count, failures, pending = 3.5, 10, 3, 2
107
- send_notification :dump_summary, summary_notification(duration, count, failures, pending)
108
- expect(output.string).to(
109
- match("Finished in 3.5").
110
- and match("3/10 failed.").
111
- and match("2 pending.")
112
- )
113
- end
114
- end
115
-
116
- describe "#dump_pending" do
117
- it "notifies formatter of dump_pending" do
118
- send_notification :dump_pending, null_notification
119
- expect(output.string).to match "Pending:"
120
- end
121
- end
122
-
123
- describe "#seed" do
124
- it "notifies formatter of seed" do
125
- send_notification :seed, seed_notification(17)
126
- expect(output.string).to match "Randomized with seed 17"
127
- end
128
- end
129
-
130
- describe "#close" do
131
- it "notifies formatter of close" do
132
- send_notification :close, null_notification
133
- end
134
- end
135
- end
136
- end
137
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/progress_formatter'
3
-
4
- RSpec.describe RSpec::Core::Formatters::ProgressFormatter do
5
- include FormatterSupport
6
-
7
- before do
8
- send_notification :start, count_notification(2)
9
- allow(formatter).to receive(:color_enabled?).and_return(false)
10
- end
11
-
12
- it 'prints a . on example_passed' do
13
- send_notification :example_passed, example_notification
14
- expect(output.string).to eq(".")
15
- end
16
-
17
- it 'prints a * on example_pending' do
18
- send_notification :example_pending, example_notification
19
- expect(output.string).to eq("*")
20
- end
21
-
22
- it 'prints a F on example_failed' do
23
- send_notification :example_failed, example_notification
24
- expect(output.string).to eq("F")
25
- end
26
-
27
- it "produces standard summary without pending when pending has a 0 count" do
28
- send_notification :dump_summary, summary_notification(0.00001, 2, 0, 0)
29
- expect(output.string).to match(/^\n/)
30
- expect(output.string).to match(/2 examples, 0 failures/i)
31
- expect(output.string).not_to match(/0 pending/i)
32
- end
33
-
34
- it "pushes nothing on start" do
35
- #start already sent
36
- expect(output.string).to eq("")
37
- end
38
-
39
- it "pushes nothing on start dump" do
40
- send_notification :start_dump, null_notification
41
- expect(output.string).to eq("\n")
42
- end
43
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- require 'rspec/core/formatters/snippet_extractor'
3
-
4
- module RSpec
5
- module Core
6
- module Formatters
7
- RSpec.describe SnippetExtractor do
8
- it "falls back on a default message when it doesn't understand a line" do
9
- expect(RSpec::Core::Formatters::SnippetExtractor.new.snippet_for("blech")).to eq(["# Couldn't get snippet for blech", 1])
10
- end
11
-
12
- it "falls back on a default message when it doesn't find the file" do
13
- expect(RSpec::Core::Formatters::SnippetExtractor.new.lines_around("blech", 8)).to eq("# Couldn't get snippet for blech")
14
- end
15
-
16
- it "falls back on a default message when it gets a security error" do
17
- message = nil
18
- safely do
19
- message = RSpec::Core::Formatters::SnippetExtractor.new.lines_around("blech", 8)
20
- end
21
- expect(message).to eq("# Couldn't get snippet for blech")
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,120 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec::Core::Formatters
4
- describe Loader do
5
-
6
- describe "#add(formatter)" do
7
- let(:loader) { Loader.new reporter }
8
- let(:output) { StringIO.new }
9
- let(:path) { File.join(Dir.tmpdir, 'output.txt') }
10
- let(:reporter) { double "reporter", :register_listener => nil }
11
-
12
- it "adds to the list of formatters" do
13
- loader.add :documentation, output
14
- expect(loader.formatters.first).to be_an_instance_of(DocumentationFormatter)
15
- end
16
-
17
- it "finds a formatter by name (w/ Symbol)" do
18
- loader.add :documentation, output
19
- expect(loader.formatters.first).to be_an_instance_of(DocumentationFormatter)
20
- end
21
-
22
- it "finds a formatter by name (w/ String)" do
23
- loader.add 'documentation', output
24
- expect(loader.formatters.first).to be_an_instance_of(DocumentationFormatter)
25
- end
26
-
27
- it "finds a formatter by class" do
28
- formatter_class = Class.new(BaseTextFormatter)
29
- Loader.formatters[formatter_class] = []
30
- loader.add formatter_class, output
31
- expect(loader.formatters.first).to be_an_instance_of(formatter_class)
32
- end
33
-
34
- it "finds a formatter by class name" do
35
- stub_const("CustomFormatter", Class.new(BaseFormatter))
36
- Loader.formatters[CustomFormatter] = []
37
- loader.add "CustomFormatter", output
38
- expect(loader.formatters.first).to be_an_instance_of(CustomFormatter)
39
- end
40
-
41
- it "handles formatters that dont implement notifications" do
42
- formatter_class = Struct.new(:output)
43
- loader.add formatter_class, output
44
- expect(loader.formatters.first).to be_an_instance_of(RSpec::Core::Formatters::LegacyFormatter)
45
- end
46
-
47
- context "when a legacy formatter is added" do
48
- formatter_class = Struct.new(:output)
49
-
50
- it "issues a deprecation" do
51
- expect_warn_deprecation_with_call_site(__FILE__, __LINE__ + 2,
52
- /The #{formatter_class} formatter uses the deprecated formatter interface/)
53
- loader.add formatter_class, output
54
- end
55
-
56
- it "does not mistakenly add in the progress formatter" do
57
- # When we issue a deprecation warning it triggers `setup_defaults`,
58
- # which adds the progress formatter if it thinks no formatter has been
59
- # added yet.
60
- allow(RSpec).to receive(:warn_deprecation) do
61
- loader.setup_default(StringIO.new, StringIO.new)
62
- end
63
-
64
- loader.add formatter_class, output
65
-
66
- expect(loader.formatters.grep(RSpec::Core::Formatters::ProgressFormatter)).to eq([])
67
- end
68
- end
69
-
70
- it "finds a formatter by class fully qualified name" do
71
- stub_const("RSpec::CustomFormatter", (Class.new(BaseFormatter)))
72
- Loader.formatters[RSpec::CustomFormatter] = []
73
- loader.add "RSpec::CustomFormatter", output
74
- expect(loader.formatters.first).to be_an_instance_of(RSpec::CustomFormatter)
75
- end
76
-
77
- it "requires a formatter file based on its fully qualified name" do
78
- expect(loader).to receive(:require).with('rspec/custom_formatter') do
79
- stub_const("RSpec::CustomFormatter", (Class.new(BaseFormatter)))
80
- Loader.formatters[RSpec::CustomFormatter] = []
81
- end
82
- loader.add "RSpec::CustomFormatter", output
83
- expect(loader.formatters.first).to be_an_instance_of(RSpec::CustomFormatter)
84
- end
85
-
86
- it "raises NameError if class is unresolvable" do
87
- expect(loader).to receive(:require).with('rspec/custom_formatter3')
88
- expect { loader.add "RSpec::CustomFormatter3", output }.to raise_error(NameError)
89
- end
90
-
91
- it "raises ArgumentError if formatter is unknown" do
92
- expect { loader.add :progresss, output }.to raise_error(ArgumentError)
93
- end
94
-
95
- context "with a 2nd arg defining the output" do
96
- it "creates a file at that path and sets it as the output" do
97
- loader.add('doc', path)
98
- expect(loader.formatters.first.output).to be_a(File)
99
- expect(loader.formatters.first.output.path).to eq(path)
100
- end
101
- end
102
-
103
- context "when a duplicate formatter exists" do
104
- before { loader.add :documentation, output }
105
-
106
- it "doesn't add the formatter for the same output target" do
107
- expect {
108
- loader.add :documentation, output
109
- }.not_to change { loader.formatters.length }
110
- end
111
-
112
- it "adds the formatter for different output targets" do
113
- expect {
114
- loader.add :documentation, path
115
- }.to change { loader.formatters.length }
116
- end
117
- end
118
- end
119
- end
120
- end