rspec-core 2.12.2 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/Changelog.md +31 -0
  2. data/README.md +11 -10
  3. data/features/command_line/example_name_option.feature +6 -10
  4. data/features/command_line/tag.feature +15 -8
  5. data/features/configuration/backtrace_clean_patterns.feature +102 -0
  6. data/features/configuration/failure_exit_code.feature +36 -0
  7. data/features/configuration/order_and_seed.feature +3 -0
  8. data/features/configuration/output_stream.feature +24 -0
  9. data/features/configuration/pattern.feature +30 -0
  10. data/features/configuration/profile.feature +163 -0
  11. data/features/configuration/run_all_when_everything_filtered.feature +60 -0
  12. data/features/configuration/show_failures_in_pending_blocks.feature +61 -0
  13. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +52 -0
  14. data/features/filtering/exclusion_filters.feature +1 -2
  15. data/features/formatters/configurable_colors.feature +31 -0
  16. data/features/step_definitions/additional_cli_steps.rb +21 -0
  17. data/features/subject/explicit_subject.feature +19 -0
  18. data/lib/autotest/rspec2.rb +1 -1
  19. data/lib/rspec/core.rb +1 -2
  20. data/lib/rspec/core/configuration.rb +33 -3
  21. data/lib/rspec/core/configuration_options.rb +5 -5
  22. data/lib/rspec/core/deprecation.rb +1 -1
  23. data/lib/rspec/core/example.rb +2 -2
  24. data/lib/rspec/core/example_group.rb +1 -3
  25. data/lib/rspec/core/formatters/base_text_formatter.rb +93 -27
  26. data/lib/rspec/core/formatters/documentation_formatter.rb +3 -3
  27. data/lib/rspec/core/formatters/progress_formatter.rb +3 -3
  28. data/lib/rspec/core/memoized_helpers.rb +425 -0
  29. data/lib/rspec/core/metadata.rb +6 -2
  30. data/lib/rspec/core/option_parser.rb +8 -2
  31. data/lib/rspec/core/pending.rb +7 -0
  32. data/lib/rspec/core/shared_context.rb +1 -1
  33. data/lib/rspec/core/version.rb +1 -1
  34. data/spec/autotest/failed_results_re_spec.rb +4 -4
  35. data/spec/autotest/rspec_spec.rb +25 -20
  36. data/spec/command_line/order_spec.rb +21 -21
  37. data/spec/rspec/core/command_line_spec.rb +6 -6
  38. data/spec/rspec/core/configuration_options_spec.rb +86 -72
  39. data/spec/rspec/core/configuration_spec.rb +161 -156
  40. data/spec/rspec/core/deprecations_spec.rb +4 -4
  41. data/spec/rspec/core/drb_command_line_spec.rb +9 -9
  42. data/spec/rspec/core/drb_options_spec.rb +46 -33
  43. data/spec/rspec/core/dsl_spec.rb +3 -3
  44. data/spec/rspec/core/example_group_spec.rb +156 -124
  45. data/spec/rspec/core/example_spec.rb +68 -52
  46. data/spec/rspec/core/filter_manager_spec.rb +36 -36
  47. data/spec/rspec/core/formatters/base_formatter_spec.rb +9 -9
  48. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +104 -42
  49. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +4 -4
  50. data/spec/rspec/core/formatters/helpers_spec.rb +13 -13
  51. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +5 -17
  52. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +159 -44
  53. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -14
  54. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +20 -20
  55. data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +5 -5
  56. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +159 -44
  57. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +20 -20
  58. data/spec/rspec/core/formatters/{html_formatted-1.9.2-jruby.html → html_formatted-2.0.0.html} +24 -18
  59. data/spec/rspec/core/formatters/html_formatter_spec.rb +9 -5
  60. data/spec/rspec/core/formatters/json_formatter_spec.rb +9 -9
  61. data/spec/rspec/core/formatters/progress_formatter_spec.rb +4 -4
  62. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +3 -3
  63. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +5 -17
  64. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +159 -44
  65. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +16 -16
  66. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +23 -23
  67. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +5 -17
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +159 -44
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +23 -23
  70. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.2-jruby.html → text_mate_formatted-2.0.0.html} +25 -19
  71. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +8 -4
  72. data/spec/rspec/core/hooks_filtering_spec.rb +16 -16
  73. data/spec/rspec/core/hooks_spec.rb +11 -11
  74. data/spec/rspec/core/kernel_extensions_spec.rb +1 -1
  75. data/spec/rspec/core/memoized_helpers_spec.rb +458 -0
  76. data/spec/rspec/core/metadata_spec.rb +74 -74
  77. data/spec/rspec/core/option_parser_spec.rb +27 -27
  78. data/spec/rspec/core/pending_example_spec.rb +32 -32
  79. data/spec/rspec/core/project_initializer_spec.rb +8 -8
  80. data/spec/rspec/core/rake_task_spec.rb +16 -16
  81. data/spec/rspec/core/reporter_spec.rb +3 -3
  82. data/spec/rspec/core/resources/formatter_specs.rb +4 -4
  83. data/spec/rspec/core/ruby_project_spec.rb +4 -2
  84. data/spec/rspec/core/shared_context_spec.rb +34 -7
  85. data/spec/rspec/core/shared_example_group_spec.rb +14 -14
  86. data/spec/rspec/core/world_spec.rb +9 -9
  87. data/spec/rspec/core_spec.rb +5 -5
  88. data/spec/spec_helper.rb +4 -0
  89. data/spec/support/shared_example_groups.rb +4 -4
  90. data/spec/support/spec_files.rb +2 -2
  91. metadata +158 -150
  92. data/lib/rspec/core/let.rb +0 -110
  93. data/lib/rspec/core/subject.rb +0 -223
  94. data/spec/rspec/core/let_spec.rb +0 -55
  95. data/spec/rspec/core/subject_spec.rb +0 -255
@@ -8,13 +8,13 @@ describe RSpec::Core::Formatters::BaseFormatter do
8
8
 
9
9
  describe "backtrace_line" do
10
10
  it "trims current working directory" do
11
- formatter.__send__(:backtrace_line, File.expand_path(__FILE__)).should eq("./spec/rspec/core/formatters/base_formatter_spec.rb")
11
+ expect(formatter.__send__(:backtrace_line, File.expand_path(__FILE__))).to eq("./spec/rspec/core/formatters/base_formatter_spec.rb")
12
12
  end
13
13
 
14
14
  it "leaves the original line intact" do
15
15
  original_line = File.expand_path(__FILE__)
16
16
  formatter.__send__(:backtrace_line, original_line)
17
- original_line.should eq(File.expand_path(__FILE__))
17
+ expect(original_line).to eq(File.expand_path(__FILE__))
18
18
  end
19
19
 
20
20
  it "deals gracefully with a security error" do
@@ -35,18 +35,18 @@ describe RSpec::Core::Formatters::BaseFormatter do
35
35
  "/some/line/of/ruby.rb:14"
36
36
  ])
37
37
  example = mock(:Example, :file_path => __FILE__)
38
- lambda {
38
+ expect {
39
39
  formatter.send(:read_failed_line, exception, example)
40
- }.should_not raise_error
40
+ }.not_to raise_error
41
41
  end
42
42
 
43
43
  it "deals gracefully with a security error" do
44
44
  exception = mock(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
45
45
  example = mock(:Example, :file_path => __FILE__)
46
46
  safely do
47
- lambda {
47
+ expect {
48
48
  formatter.send(:read_failed_line, exception, example)
49
- }.should_not raise_error
49
+ }.not_to raise_error
50
50
  end
51
51
  end
52
52
 
@@ -78,8 +78,8 @@ describe RSpec::Core::Formatters::BaseFormatter do
78
78
  exception = mock(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
79
79
 
80
80
  example = mock(:Example, :file_path => __FILE__)
81
- formatter.send(:read_failed_line, exception, example).should
82
- eql(%Q{ exception = mock(:Exception, :backtrace => [ "\#{__FILE__}:\#{__LINE__}"])\n})
81
+ expect(formatter.send(:read_failed_line, exception, example)).to eql(
82
+ %Q{ exception = mock(:Exception, :backtrace => [ "\#{__FILE__}:\#{__LINE__}"])\n})
83
83
  end
84
84
 
85
85
  end
@@ -101,7 +101,7 @@ describe RSpec::Core::Formatters::BaseFormatter do
101
101
  end
102
102
 
103
103
  it "removes lines from rspec and lines that come before the invocation of the at_exit autorun hook" do
104
- formatter.format_backtrace(backtrace, stub.as_null_object).should eq(["./my_spec.rb:5"])
104
+ expect(formatter.format_backtrace(backtrace, stub.as_null_object)).to eq(["./my_spec.rb:5"])
105
105
  end
106
106
  end
107
107
 
@@ -7,15 +7,15 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
7
7
 
8
8
  describe "#summary_line" do
9
9
  it "with 0s outputs pluralized (excluding pending)" do
10
- formatter.summary_line(0,0,0).should eq("0 examples, 0 failures")
10
+ expect(formatter.summary_line(0,0,0)).to eq("0 examples, 0 failures")
11
11
  end
12
12
 
13
13
  it "with 1s outputs singular (including pending)" do
14
- formatter.summary_line(1,1,1).should eq("1 example, 1 failure, 1 pending")
14
+ expect(formatter.summary_line(1,1,1)).to eq("1 example, 1 failure, 1 pending")
15
15
  end
16
16
 
17
17
  it "with 2s outputs pluralized (including pending)" do
18
- formatter.summary_line(2,2,2).should eq("2 examples, 2 failures, 2 pending")
18
+ expect(formatter.summary_line(2,2,2)).to eq("2 examples, 2 failures, 2 pending")
19
19
  end
20
20
  end
21
21
 
@@ -27,7 +27,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
27
27
  line = __LINE__ - 2
28
28
  group.run(formatter)
29
29
  formatter.dump_commands_to_rerun_failed_examples
30
- output.string.should include("rspec #{RSpec::Core::Metadata::relative_path("#{__FILE__}:#{line}")} # example group fails")
30
+ expect(output.string).to include("rspec #{RSpec::Core::Metadata::relative_path("#{__FILE__}:#{line}")} # example group fails")
31
31
  end
32
32
  end
33
33
 
@@ -42,12 +42,12 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
42
42
  end
43
43
 
44
44
  it "preserves formatting" do
45
- group.example("example name") { "this".should eq("that") }
45
+ group.example("example name") { expect("this").to eq("that") }
46
46
 
47
47
  run_all_and_dump_failures
48
48
 
49
- output.string.should =~ /group name example name/m
50
- output.string.should =~ /(\s+)expected: \"that\"\n\1 got: \"this\"/m
49
+ expect(output.string).to match /group name example name/m
50
+ expect(output.string).to match /(\s+)expected: \"that\"\n\1 got: \"this\"/m
51
51
  end
52
52
 
53
53
  context "with an exception without a message" do
@@ -61,7 +61,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
61
61
  it "preserves ancestry" do
62
62
  example = group.example("example name") { raise "something" }
63
63
  run_all_and_dump_failures
64
- example.example_group.parent_groups.size.should == 1
64
+ expect(example.example_group.parent_groups.size).to eq 1
65
65
  end
66
66
  end
67
67
 
@@ -74,19 +74,28 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
74
74
  end
75
75
  end
76
76
 
77
+ context "with an instance of an anonymous exception class" do
78
+ it "substitutes '(anonymous error class)' for the missing class name" do
79
+ exception = Class.new(StandardError).new
80
+ group.example("example name") { raise exception }
81
+ run_all_and_dump_failures
82
+ expect(output.string).to include('(anonymous error class)')
83
+ end
84
+ end
85
+
77
86
  context "with an exception class other than RSpec" do
78
87
  it "does not show the error class" do
79
88
  group.example("example name") { raise NameError.new('foo') }
80
89
  run_all_and_dump_failures
81
- output.string.should =~ /NameError/m
90
+ expect(output.string).to match /NameError/m
82
91
  end
83
92
  end
84
93
 
85
94
  context "with a failed expectation (rspec-expectations)" do
86
95
  it "does not show the error class" do
87
- group.example("example name") { "this".should eq("that") }
96
+ group.example("example name") { expect("this").to eq("that") }
88
97
  run_all_and_dump_failures
89
- output.string.should_not =~ /RSpec/m
98
+ expect(output.string).not_to match /RSpec/m
90
99
  end
91
100
  end
92
101
 
@@ -94,7 +103,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
94
103
  it "does not show the error class" do
95
104
  group.example("example name") { "this".should_receive("that") }
96
105
  run_all_and_dump_failures
97
- output.string.should_not =~ /RSpec/m
106
+ expect(output.string).not_to match /RSpec/m
98
107
  end
99
108
  end
100
109
 
@@ -102,7 +111,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
102
111
  it 'outputs the name and location' do
103
112
 
104
113
  share_examples_for 'foo bar' do
105
- it("example name") { "this".should eq("that") }
114
+ it("example name") { expect("this").to eq("that") }
106
115
  end
107
116
 
108
117
  line = __LINE__.next
@@ -110,7 +119,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
110
119
 
111
120
  run_all_and_dump_failures
112
121
 
113
- output.string.should include(
122
+ expect(output.string).to include(
114
123
  'Shared Example Group: "foo bar" called from ' +
115
124
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
116
125
  )
@@ -120,7 +129,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
120
129
  it 'outputs the name and location' do
121
130
  share_examples_for 'foo bar' do
122
131
  describe 'nested group' do
123
- it("example name") { "this".should eq("that") }
132
+ it("example name") { expect("this").to eq("that") }
124
133
  end
125
134
  end
126
135
 
@@ -129,7 +138,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
129
138
 
130
139
  run_all_and_dump_failures
131
140
 
132
- output.string.should include(
141
+ expect(output.string).to include(
133
142
  'Shared Example Group: "foo bar" called from ' +
134
143
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
135
144
  )
@@ -143,7 +152,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
143
152
  it 'outputs the name and location' do
144
153
 
145
154
  share_as :FooBar do
146
- it("example name") { "this".should eq("that") }
155
+ it("example name") { expect("this").to eq("that") }
147
156
  end
148
157
 
149
158
  line = __LINE__.next
@@ -151,7 +160,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
151
160
 
152
161
  run_all_and_dump_failures
153
162
 
154
- output.string.should include(
163
+ expect(output.string).to include(
155
164
  'Shared Example Group: "FooBar" called from ' +
156
165
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
157
166
  )
@@ -163,7 +172,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
163
172
  share_as :NestedFoo do
164
173
  describe 'nested group' do
165
174
  describe 'hell' do
166
- it("example name") { "this".should eq("that") }
175
+ it("example name") { expect("this").to eq("that") }
167
176
  end
168
177
  end
169
178
  end
@@ -173,7 +182,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
173
182
 
174
183
  run_all_and_dump_failures
175
184
 
176
- output.string.should include(
185
+ expect(output.string).to include(
177
186
  'Shared Example Group: "NestedFoo" called from ' +
178
187
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
179
188
  )
@@ -196,12 +205,12 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
196
205
  before { RSpec.configuration.stub(:show_failures_in_pending_blocks?) { true } }
197
206
 
198
207
  it "preserves formatting" do
199
- group.example("example name") { pending { "this".should eq("that") } }
208
+ group.example("example name") { pending { expect("this").to eq("that") } }
200
209
 
201
210
  run_all_and_dump_pending
202
211
 
203
- output.string.should =~ /group name example name/m
204
- output.string.should =~ /(\s+)expected: \"that\"\n\1 got: \"this\"/m
212
+ expect(output.string).to match /group name example name/m
213
+ expect(output.string).to match /(\s+)expected: \"that\"\n\1 got: \"this\"/m
205
214
  end
206
215
 
207
216
  context "with an exception without a message" do
@@ -217,15 +226,15 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
217
226
  it "does not show the error class" do
218
227
  group.example("example name") { pending { raise NameError.new('foo') } }
219
228
  run_all_and_dump_pending
220
- output.string.should =~ /NameError/m
229
+ expect(output.string).to match /NameError/m
221
230
  end
222
231
  end
223
232
 
224
233
  context "with a failed expectation (rspec-expectations)" do
225
234
  it "does not show the error class" do
226
- group.example("example name") { pending { "this".should eq("that") } }
235
+ group.example("example name") { pending { expect("this").to eq("that") } }
227
236
  run_all_and_dump_pending
228
- output.string.should_not =~ /RSpec/m
237
+ expect(output.string).not_to match /RSpec/m
229
238
  end
230
239
  end
231
240
 
@@ -233,7 +242,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
233
242
  it "does not show the error class" do
234
243
  group.example("example name") { pending { "this".should_receive("that") } }
235
244
  run_all_and_dump_pending
236
- output.string.should_not =~ /RSpec/m
245
+ expect(output.string).not_to match /RSpec/m
237
246
  end
238
247
  end
239
248
 
@@ -241,7 +250,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
241
250
  it 'outputs the name and location' do
242
251
 
243
252
  share_examples_for 'foo bar' do
244
- it("example name") { pending { "this".should eq("that") } }
253
+ it("example name") { pending { expect("this").to eq("that") } }
245
254
  end
246
255
 
247
256
  line = __LINE__.next
@@ -249,7 +258,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
249
258
 
250
259
  run_all_and_dump_pending
251
260
 
252
- output.string.should include(
261
+ expect(output.string).to include(
253
262
  'Shared Example Group: "foo bar" called from ' +
254
263
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
255
264
  )
@@ -259,7 +268,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
259
268
  it 'outputs the name and location' do
260
269
  share_examples_for 'foo bar' do
261
270
  describe 'nested group' do
262
- it("example name") { pending { "this".should eq("that") } }
271
+ it("example name") { pending { expect("this").to eq("that") } }
263
272
  end
264
273
  end
265
274
 
@@ -268,7 +277,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
268
277
 
269
278
  run_all_and_dump_pending
270
279
 
271
- output.string.should include(
280
+ expect(output.string).to include(
272
281
  'Shared Example Group: "foo bar" called from ' +
273
282
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
274
283
  )
@@ -282,7 +291,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
282
291
  it 'outputs the name and location' do
283
292
 
284
293
  share_as :FooBar2 do
285
- it("example name") { pending { "this".should eq("that") } }
294
+ it("example name") { pending { expect("this").to eq("that") } }
286
295
  end
287
296
 
288
297
  line = __LINE__.next
@@ -290,7 +299,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
290
299
 
291
300
  run_all_and_dump_pending
292
301
 
293
- output.string.should include(
302
+ expect(output.string).to include(
294
303
  'Shared Example Group: "FooBar2" called from ' +
295
304
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
296
305
  )
@@ -302,7 +311,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
302
311
  share_as :NestedFoo2 do
303
312
  describe 'nested group' do
304
313
  describe 'hell' do
305
- it("example name") { pending { "this".should eq("that") } }
314
+ it("example name") { pending { expect("this").to eq("that") } }
306
315
  end
307
316
  end
308
317
  end
@@ -312,7 +321,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
312
321
 
313
322
  run_all_and_dump_pending
314
323
 
315
- output.string.should include(
324
+ expect(output.string).to include(
316
325
  'Shared Example Group: "NestedFoo2" called from ' +
317
326
  "./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
318
327
  )
@@ -325,43 +334,96 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
325
334
  before { RSpec.configuration.stub(:show_failures_in_pending_blocks?) { false } }
326
335
 
327
336
  it "does not output the failure information" do
328
- group.example("example name") { pending { "this".should eq("that") } }
337
+ group.example("example name") { pending { expect("this").to eq("that") } }
329
338
  run_all_and_dump_pending
330
- output.string.should_not =~ /(\s+)expected: \"that\"\n\1 got: \"this\"/m
339
+ expect(output.string).not_to match /(\s+)expected: \"that\"\n\1 got: \"this\"/m
331
340
  end
332
341
  end
333
342
  end
334
343
 
335
344
  describe "#dump_profile" do
345
+ example_line_number = nil
346
+
336
347
  before do
337
348
  group = RSpec::Core::ExampleGroup.describe("group") do
338
- example("example") { sleep 0.1 }
349
+ # Use a sleep so there is some measurable time, to ensure
350
+ # the reported percent is 100%, not 0%.
351
+ example("example") { sleep 0.001 }
352
+ example_line_number = __LINE__ - 1
339
353
  end
340
354
  group.run(double('reporter').as_null_object)
341
355
 
342
356
  formatter.stub(:examples) { group.examples }
357
+ RSpec.configuration.stub(:profile_examples) { 10 }
343
358
  end
344
359
 
345
360
  it "names the example" do
346
361
  formatter.dump_profile
347
- output.string.should =~ /group example/m
362
+ expect(output.string).to match /group example/m
348
363
  end
349
364
 
350
365
  it "prints the time" do
351
366
  formatter.dump_profile
352
- output.string.should =~ /0(\.\d+)? seconds/
367
+ expect(output.string).to match /0(\.\d+)? seconds/
353
368
  end
354
369
 
355
370
  it "prints the path" do
356
371
  formatter.dump_profile
357
372
  filename = __FILE__.split(File::SEPARATOR).last
358
373
 
359
- output.string.should =~ /#{filename}\:#{__LINE__ - 21}/
374
+ expect(output.string).to match /#{filename}\:#{example_line_number}/
360
375
  end
361
376
 
362
377
  it "prints the percentage taken from the total runtime" do
363
378
  formatter.dump_profile
364
- output.string.should =~ /, 100.0% of total time\):/
379
+ expect(output.string).to match /, 100.0% of total time\):/
380
+ end
381
+ end
382
+
383
+ describe "custom_colors" do
384
+ it "uses the custom success color" do
385
+ RSpec.configure do |config|
386
+ config.color_enabled = true
387
+ config.tty = true
388
+ config.success_color = :cyan
389
+ end
390
+ formatter.dump_summary(0,1,0,0)
391
+ expect(output.string).to include("\e[36m")
392
+ end
393
+ end
394
+
395
+ describe "#colorize" do
396
+ it "accepts a VT100 integer code and formats the text with it" do
397
+ expect(formatter.colorize('abc', 32)).to eq "\e[32mabc\e[0m"
398
+ end
399
+
400
+ it "accepts a symbol as a color parameter and translates it to the correct integer code, then formats the text with it" do
401
+ expect(formatter.colorize('abc', :green)).to eq "\e[32mabc\e[0m"
402
+ end
403
+
404
+ it "accepts a non-default color symbol as a parameter and translates it to the correct integer code, then formats the text with it" do
405
+ expect(formatter.colorize('abc', :cyan)).to eq "\e[36mabc\e[0m"
365
406
  end
366
407
  end
408
+
409
+ described_class::VT100_COLORS.each do |name, number|
410
+ next if name == :black
411
+
412
+ describe "##{name}" do
413
+ before do
414
+ RSpec.configuration.stub(:color_enabled?) { true }
415
+ RSpec.stub(:warn)
416
+ end
417
+
418
+ it "prints the text using the color code for #{name}" do
419
+ expect(formatter.send(name, "text")).to eq("\e[#{number}mtext\e[0m")
420
+ end
421
+
422
+ it "prints a deprecation warning" do
423
+ RSpec.should_receive(:warn).with(/#{name}/)
424
+ formatter.send(name, "text")
425
+ end
426
+ end
427
+ end
428
+
367
429
  end
@@ -23,8 +23,8 @@ module RSpec::Core::Formatters
23
23
 
24
24
  examples.each {|e| formatter.example_failed(e) }
25
25
 
26
- output.string.should =~ /first example \(FAILED - 1\)/m
27
- output.string.should =~ /second example \(FAILED - 2\)/m
26
+ expect(output.string).to match /first example \(FAILED - 1\)/m
27
+ expect(output.string).to match /second example \(FAILED - 2\)/m
28
28
  end
29
29
 
30
30
  it "represents nested group using hierarchy tree" do
@@ -48,7 +48,7 @@ module RSpec::Core::Formatters
48
48
 
49
49
  group.run(RSpec::Core::Reporter.new(formatter))
50
50
 
51
- output.string.should eql("
51
+ expect(output.string).to eql("
52
52
  root
53
53
  context 1
54
54
  nested example 1.1
@@ -76,7 +76,7 @@ root
76
76
 
77
77
  group.run(RSpec::Core::Reporter.new(formatter))
78
78
 
79
- output.string.should eql("
79
+ expect(output.string).to eql("
80
80
  root
81
81
  nested
82
82
  example 1