rspec-core 2.99.0.beta1 → 2.99.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/Changelog.md +40 -0
  2. data/features/command_line/line_number_option.feature +2 -2
  3. data/features/example_groups/basic_structure.feature +1 -1
  4. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  5. data/features/subject/explicit_subject.feature +1 -1
  6. data/features/subject/one_liner_syntax.feature +71 -0
  7. data/lib/rspec/core/caller_filter.rb +50 -45
  8. data/lib/rspec/core/configuration.rb +59 -19
  9. data/lib/rspec/core/example.rb +1 -1
  10. data/lib/rspec/core/example_group.rb +20 -0
  11. data/lib/rspec/core/formatters/base_text_formatter.rb +3 -1
  12. data/lib/rspec/core/formatters/deprecation_formatter.rb +34 -16
  13. data/lib/rspec/core/memoized_helpers.rb +40 -6
  14. data/lib/rspec/core/option_parser.rb +1 -1
  15. data/lib/rspec/core/pending.rb +29 -1
  16. data/lib/rspec/core/reporter.rb +4 -1
  17. data/lib/rspec/core/version.rb +1 -1
  18. data/spec/rspec/core/configuration_options_spec.rb +3 -3
  19. data/spec/rspec/core/configuration_spec.rb +96 -4
  20. data/spec/rspec/core/example_group_spec.rb +36 -14
  21. data/spec/rspec/core/filter_manager_spec.rb +2 -2
  22. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +1 -1
  23. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +46 -0
  24. data/spec/rspec/core/formatters/{html_formatted-1.8.7-jruby.html → html_formatted.html} +24 -30
  25. data/spec/rspec/core/formatters/html_formatter_spec.rb +30 -15
  26. data/spec/rspec/core/formatters/{html_formatted-1.9.3-jruby.html → text_mate_formatted.html} +24 -30
  27. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +38 -33
  28. data/spec/rspec/core/memoized_helpers_spec.rb +11 -2
  29. data/spec/rspec/core/pending_example_spec.rb +26 -0
  30. data/spec/rspec/core/reporter_spec.rb +26 -0
  31. data/spec/rspec/core_spec.rb +1 -1
  32. data/spec/support/sandboxed_mock_space.rb +16 -0
  33. data/spec/support/silence_dsl_deprecations.rb +1 -1
  34. metadata +35 -40
  35. checksums.yaml +0 -15
  36. data/features/subject/implicit_receiver.feature +0 -29
  37. data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +0 -477
  38. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +0 -414
  39. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -425
  40. data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +0 -477
  41. data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -425
  42. data/spec/rspec/core/formatters/html_formatted-2.0.0.html +0 -425
  43. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +0 -395
  44. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +0 -477
  45. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +0 -414
  46. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +0 -425
  47. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +0 -404
  48. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +0 -477
  49. data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +0 -425
  50. data/spec/rspec/core/formatters/text_mate_formatted-2.0.0.html +0 -425
@@ -693,30 +693,52 @@ module RSpec::Core
693
693
  end
694
694
  end
695
695
 
696
- %w[pending xit xspecify xexample].each do |method_name|
697
- describe "::#{method_name}" do
698
- before do
699
- @group = ExampleGroup.describe
700
- @group.send(method_name, "is pending") { }
701
- end
696
+ %w[pending skip].each do |method_name|
697
+ describe ".#{method_name}" do
698
+ let(:group) { ExampleGroup.describe.tap {|x|
699
+ x.send(method_name, "is pending") { }
700
+ }}
702
701
 
703
702
  it "generates a pending example" do
704
- @group.run
705
- expect(@group.examples.first).to be_pending
703
+ group.run
704
+ expect(group.examples.first).to be_pending
705
+ end
706
+
707
+ it "sets the pending message" do
708
+ group.run
709
+ expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
706
710
  end
711
+ end
712
+ end
707
713
 
708
- it "sets the pending message", :if => method_name == 'pending' do
709
- @group.run
710
- expect(@group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
714
+ %w[xit xspecify xexample].each do |method_name|
715
+ describe ".#{method_name}" do
716
+ let(:group) { ExampleGroup.describe.tap {|x|
717
+ x.send(method_name, "is pending") { }
718
+ }}
719
+
720
+ it "generates a pending example" do
721
+ group.run
722
+ expect(group.examples.first).to be_pending
711
723
  end
712
724
 
713
- it "sets the pending message", :unless => method_name == 'pending' do
714
- @group.run
715
- expect(@group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily disabled with #{method_name}")
725
+ it "sets the pending message" do
726
+ group.run
727
+ expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily disabled with #{method_name}")
716
728
  end
717
729
  end
718
730
  end
719
731
 
732
+ describe '::pending' do
733
+ it 'shows upgrade warning' do
734
+ expect_warn_deprecation_with_call_site(
735
+ "example_group_spec.rb", __LINE__ + 3
736
+ )
737
+ group = ExampleGroup.describe
738
+ group.send(:pending, "is pending") { }
739
+ end
740
+ end
741
+
720
742
  describe "adding examples" do
721
743
 
722
744
  it "allows adding an example using 'it'" do
@@ -165,7 +165,7 @@ module RSpec::Core
165
165
  describe "#inclusions#description" do
166
166
  it 'cleans up the description' do
167
167
  project_dir = File.expand_path('.')
168
- expect(lambda { }.inspect).to include(project_dir) unless defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.7.4'
168
+ expect(lambda { }.inspect).to include(project_dir) unless defined?(JRUBY_VERSION) && JRUBY_VERSION =~ /\A1\.7/
169
169
  expect(lambda { }.inspect).to include(' (lambda)') if RUBY_VERSION > '1.9'
170
170
  expect(lambda { }.inspect).to include('0x')
171
171
 
@@ -181,7 +181,7 @@ module RSpec::Core
181
181
  describe "#exclusions#description" do
182
182
  it 'cleans up the description' do
183
183
  project_dir = File.expand_path('.')
184
- expect(lambda { }.inspect).to include(project_dir) unless defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.7.4'
184
+ expect(lambda { }.inspect).to include(project_dir) unless defined?(JRUBY_VERSION) && JRUBY_VERSION =~ /\A1\.7/
185
185
  expect(lambda { }.inspect).to include(' (lambda)') if RUBY_VERSION > '1.9'
186
186
  expect(lambda { }.inspect).to include('0x')
187
187
 
@@ -202,7 +202,7 @@ describe RSpec::Core::Formatters::BaseTextFormatter do
202
202
  end
203
203
 
204
204
  context "with show_failures_in_pending_blocks setting enabled" do
205
- before { RSpec.configuration.stub(:show_failures_in_pending_blocks?) { true } }
205
+ before { RSpec.configuration.instance_variable_set(:@show_failures_in_pending_blocks, true) }
206
206
 
207
207
  it "preserves formatting" do
208
208
  group.example("example name") { pending { expect("this").to eq("that") } }
@@ -108,6 +108,27 @@ module RSpec::Core::Formatters
108
108
  end
109
109
  end
110
110
 
111
+ context "with an Error deprecation_stream" do
112
+ let(:deprecation_stream) { DeprecationFormatter::RaiseErrorStream.new }
113
+
114
+ it 'prints a summary of the number of deprecations found' do
115
+ expect { formatter.deprecation(:deprecated => 'foo') }.to raise_error(RSpec::Core::DeprecationError)
116
+
117
+ formatter.deprecation_summary
118
+
119
+ expect(summary_stream.string).to eq("\n1 deprecation found.\n")
120
+ end
121
+
122
+ it 'pluralizes the count when it is greater than 1' do
123
+ expect { formatter.deprecation(:deprecated => 'foo') }.to raise_error(RSpec::Core::DeprecationError)
124
+ expect { formatter.deprecation(:deprecated => 'bar') }.to raise_error(RSpec::Core::DeprecationError)
125
+
126
+ formatter.deprecation_summary
127
+
128
+ expect(summary_stream.string).to eq("\n2 deprecations found.\n")
129
+ end
130
+ end
131
+
111
132
  context "with an IO deprecation_stream" do
112
133
  let(:deprecation_stream) { StringIO.new }
113
134
 
@@ -148,6 +169,31 @@ module RSpec::Core::Formatters
148
169
  expect(deprecation_stream.string).to eq expected.chomp
149
170
  end
150
171
 
172
+ it "limits deprecations warnings by optional type" do
173
+ 5.times {|i|
174
+ formatter.deprecation(
175
+ :deprecated => "i_am_deprecated #{i}",
176
+ :call_site => "foo.rb:#{i + 1}",
177
+ :type => 'i_am_deprecated'
178
+ )
179
+ }
180
+ formatter.deprecation_summary
181
+
182
+ expected = <<-EOS.gsub(/^\s+\|/, '')
183
+ |
184
+ |Deprecation Warnings:
185
+ |
186
+ |i_am_deprecated 0 is deprecated. Called from foo.rb:1.
187
+ |i_am_deprecated 1 is deprecated. Called from foo.rb:2.
188
+ |i_am_deprecated 2 is deprecated. Called from foo.rb:3.
189
+ |Too many uses of deprecated 'i_am_deprecated'. Set config.deprecation_stream to a File for full output.
190
+ |
191
+ |#{DeprecationFormatter::RAISE_ERROR_CONFIG_NOTICE}
192
+ EOS
193
+ expect(deprecation_stream.string).to eq expected.chomp
194
+ end
195
+
196
+
151
197
  it "limits :message deprecation warnings with different callsites after 3 calls" do
152
198
  5.times do |n|
153
199
  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."
@@ -1,10 +1,9 @@
1
- <!DOCTYPE html>
2
- <html lang='en'>
1
+ <html lang="en">
3
2
  <head>
4
3
  <title>RSpec results</title>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <meta http-equiv="Expires" content="-1" />
7
- <meta http-equiv="Pragma" content="no-cache" />
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">
8
7
  <style type="text/css">
9
8
  body {
10
9
  margin: 0;
@@ -266,14 +265,14 @@ a {
266
265
  </div>
267
266
 
268
267
  <div id="display-filters">
269
- <input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="1" /> <label for="passed_checkbox">Passed</label>
270
- <input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="2" /> <label for="failed_checkbox">Failed</label>
271
- <input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="3" /> <label for="pending_checkbox">Pending</label>
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>
272
271
  </div>
273
272
 
274
273
  <div id="summary">
275
- <p id="totals">&#160;</p>
276
- <p id="duration">&#160;</p>
274
+ <p id="totals"> </p>
275
+ <p id="duration"> </p>
277
276
  </div>
278
277
  </div>
279
278
 
@@ -316,12 +315,9 @@ a {
316
315
  <span class="duration">n.nnnns</span>
317
316
  <div class="failure" id="failure_1">
318
317
  <div class="message"><pre>RSpec::Core::Pending::PendingExampleFixedError</pre></div>
319
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:18:in `(root)'
320
- ./spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
321
- ./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
322
- ./spec/support/sandboxed_mock_space.rb:32:in `sandboxed'</pre></div>
323
- <pre class="ruby"><code><span class="linenum">16</span> <span class="ident">context</span> <span class="punct">&quot;</span><span class="string">with content that would pass</span><span class="punct">&quot;</span> <span class="keyword">do</span>
324
- <span class="linenum">17</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">fails</span><span class="punct">&quot;</span> <span class="keyword">do</span>
318
+ <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:18</pre></div>
319
+ <pre class="ruby"><code><span class="linenum">16</span> <span class="ident">context</span> <span class="punct">"</span><span class="string">with content that would pass</span><span class="punct">"</span> <span class="keyword">do</span>
320
+ <span class="linenum">17</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">fails</span><span class="punct">"</span> <span class="keyword">do</span>
325
321
  <span class="offending"><span class="linenum">18</span> <span class="ident">pending</span> <span class="keyword">do</span></span>
326
322
  <span class="linenum">19</span> <span class="ident">expect</span><span class="punct">(</span><span class="number">1</span><span class="punct">).</span><span class="ident">to</span> <span class="ident">eq</span><span class="punct">(</span><span class="number">1</span><span class="punct">)</span>
327
323
  <span class="linenum">20</span> <span class="keyword">end</span></code></pre>
@@ -333,7 +329,9 @@ a {
333
329
  <dl style="margin-left: 0px;">
334
330
  <dt id="example_group_5" class="passed">passing spec</dt>
335
331
  <script type="text/javascript">moveProgressBar('57.1');</script>
336
- <dd class="example passed"><span class="passed_spec_name">passes</span><span class='duration'>n.nnnns</span></dd>
332
+ <dd class="example passed">
333
+ <span class="passed_spec_name">passes</span><span class="duration">n.nnnns</span>
334
+ </dd>
337
335
  </dl>
338
336
  </div>
339
337
  <div id="div_group_6" class="example_group passed">
@@ -352,12 +350,9 @@ expected: 2
352
350
 
353
351
  (compared using ==)
354
352
  </pre></div>
355
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33:in `(root)'
356
- ./spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
357
- ./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
358
- ./spec/support/sandboxed_mock_space.rb:32:in `sandboxed'</pre></div>
359
- <pre class="ruby"><code><span class="linenum">31</span><span class="ident">describe</span> <span class="punct">&quot;</span><span class="string">failing spec</span><span class="punct">&quot;</span> <span class="keyword">do</span>
360
- <span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">fails</span><span class="punct">&quot;</span> <span class="keyword">do</span>
353
+ <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33</pre></div>
354
+ <pre class="ruby"><code><span class="linenum">31</span><span class="ident">describe</span> <span class="punct">"</span><span class="string">failing spec</span><span class="punct">"</span> <span class="keyword">do</span>
355
+ <span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">fails</span><span class="punct">"</span> <span class="keyword">do</span>
361
356
  <span class="offending"><span class="linenum">33</span> <span class="ident">expect</span><span class="punct">(</span><span class="number">1</span><span class="punct">).</span><span class="ident">to</span> <span class="ident">eq</span><span class="punct">(</span><span class="number">2</span><span class="punct">)</span></span>
362
357
  <span class="linenum">34</span> <span class="keyword">end</span>
363
358
  <span class="linenum">35</span><span class="keyword">end</span></code></pre>
@@ -376,11 +371,7 @@ expected: 2
376
371
  <span class="duration">n.nnnns</span>
377
372
  <div class="failure" id="failure_3">
378
373
  <div class="message"><pre>foo</pre></div>
379
- <div class="backtrace"><pre>(erb):1:in `result'
380
- ./spec/rspec/core/resources/formatter_specs.rb:41:in `(root)'
381
- ./spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
382
- ./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
383
- ./spec/support/sandboxed_mock_space.rb:32:in `sandboxed'</pre></div>
374
+ <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:41</pre></div>
384
375
  <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
385
376
  </div>
386
377
  </dd>
@@ -390,7 +381,7 @@ expected: 2
390
381
  <span class="duration">n.nnnns</span>
391
382
  <div class="failure" id="failure_4">
392
383
  <div class="message"><pre>Exception</pre></div>
393
- <div class="backtrace"><pre>/foo.html.erb:1:in `&lt;main&gt;': foo (RuntimeError)</pre></div>
384
+ <div class="backtrace"><pre></pre></div>
394
385
  <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
395
386
  </div>
396
387
  </dd>
@@ -401,4 +392,7 @@ expected: 2
401
392
  </div>
402
393
  </div>
403
394
  </body>
404
- </html>
395
+ </html><html><p>
396
+
397
+ 2 deprecation warnings total
398
+ </p></html>
@@ -7,19 +7,10 @@ module RSpec
7
7
  module Core
8
8
  module Formatters
9
9
  describe HtmlFormatter, :if => RUBY_VERSION =~ /^(1.8.7|1.9.2|1.9.3|2.0.0)$/ do
10
- let(:suffix) {
11
- if ::RUBY_PLATFORM == 'java'
12
- "-jruby"
13
- elsif defined?(Rubinius)
14
- "-rbx"
15
- else
16
- ""
17
- end
18
- }
19
10
 
20
11
  let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
21
12
  let(:expected_file) do
22
- "#{File.dirname(__FILE__)}/html_formatted-#{::RUBY_VERSION}#{suffix}.html"
13
+ "#{File.dirname(__FILE__)}/html_formatted.html"
23
14
  end
24
15
 
25
16
  let(:generated_html) do
@@ -35,7 +26,20 @@ module RSpec
35
26
  command_line = RSpec::Core::CommandLine.new(options)
36
27
  command_line.instance_variable_get("@configuration").backtrace_cleaner.inclusion_patterns = []
37
28
  command_line.run(err, out)
38
- out.string.gsub(/\d+\.\d+(s| seconds)/, "n.nnnn\\1")
29
+ html = out.string.gsub(/\d+\.\d+(s| seconds)/, "n.nnnn\\1")
30
+
31
+ actual_doc = Nokogiri::HTML(html)
32
+ actual_doc.css("div.backtrace pre").each do |elem|
33
+ # This is to minimize churn on backtrace lines that we do not
34
+ # assert on anyway.
35
+ backtrace = elem.inner_html.lines.
36
+ select {|e| e =~ /formatter_specs\.rb/ }.
37
+ map {|x| x.chomp.split(":")[0..1].join(':') }.
38
+ join("\n")
39
+
40
+ elem.inner_html = backtrace
41
+ end
42
+ actual_doc.inner_html
39
43
  end
40
44
 
41
45
  let(:expected_html) do
@@ -68,7 +72,18 @@ module RSpec
68
72
  select {|e| e =~ /formatter_specs\.rb/}
69
73
  end
70
74
 
71
- describe 'produced HTML' do
75
+ describe 'produced HTML', :if => RUBY_VERSION <= '2.0.0' do
76
+ # Rubies before 2 are a wild west of different outputs, and it's not
77
+ # worth the effort to maintain accurate fixtures for all of them.
78
+ # Since we are verifying fixtures on other rubies, if this code at
79
+ # least runs we can be reasonably confident the output is right since
80
+ # behaviour variances that we care about across versions is neglible.
81
+ it 'is present' do
82
+ expect(generated_html).to be
83
+ end
84
+ end
85
+
86
+ describe 'produced HTML', :slow, :if => RUBY_VERSION >= '2.0.0' do
72
87
  def build_and_verify_formatter_output
73
88
  Dir.chdir(root) do
74
89
  actual_doc = Nokogiri::HTML(generated_html)
@@ -92,15 +107,15 @@ module RSpec
92
107
  end
93
108
  end
94
109
 
95
- it "produces HTML identical to the one we designed manually" do
110
+ it "is identical to the one we designed manually" do
96
111
  build_and_verify_formatter_output
97
112
  end
98
113
 
99
114
  context 'with mathn loaded' do
100
115
  include MathnIntegrationSupport
101
116
 
102
- it "produces HTML identical to the one we designed manually" do
103
- with_mathn_loaded{ build_and_verify_formatter_output }
117
+ it "is identical to the one we designed manually", :slow do
118
+ with_mathn_loaded { build_and_verify_formatter_output }
104
119
  end
105
120
  end
106
121
  end
@@ -1,10 +1,9 @@
1
- <!DOCTYPE html>
2
- <html lang='en'>
1
+ <html lang="en">
3
2
  <head>
4
3
  <title>RSpec results</title>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <meta http-equiv="Expires" content="-1" />
7
- <meta http-equiv="Pragma" content="no-cache" />
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">
8
7
  <style type="text/css">
9
8
  body {
10
9
  margin: 0;
@@ -266,14 +265,14 @@ a {
266
265
  </div>
267
266
 
268
267
  <div id="display-filters">
269
- <input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="1" /> <label for="passed_checkbox">Passed</label>
270
- <input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="2" /> <label for="failed_checkbox">Failed</label>
271
- <input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="3" /> <label for="pending_checkbox">Pending</label>
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>
272
271
  </div>
273
272
 
274
273
  <div id="summary">
275
- <p id="totals">&#160;</p>
276
- <p id="duration">&#160;</p>
274
+ <p id="totals"> </p>
275
+ <p id="duration"> </p>
277
276
  </div>
278
277
  </div>
279
278
 
@@ -316,12 +315,9 @@ a {
316
315
  <span class="duration">n.nnnns</span>
317
316
  <div class="failure" id="failure_1">
318
317
  <div class="message"><pre>RSpec::Core::Pending::PendingExampleFixedError</pre></div>
319
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:18:in `(root)'
320
- ././spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
321
- ././spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
322
- ././spec/support/sandboxed_mock_space.rb:32:in `sandboxed'</pre></div>
323
- <pre class="ruby"><code><span class="linenum">16</span> <span class="ident">context</span> <span class="punct">&quot;</span><span class="string">with content that would pass</span><span class="punct">&quot;</span> <span class="keyword">do</span>
324
- <span class="linenum">17</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">fails</span><span class="punct">&quot;</span> <span class="keyword">do</span>
318
+ <div class="backtrace"><pre>&lt;a href="txmt://open?url=file</pre></div>
319
+ <pre class="ruby"><code><span class="linenum">16</span> <span class="ident">context</span> <span class="punct">"</span><span class="string">with content that would pass</span><span class="punct">"</span> <span class="keyword">do</span>
320
+ <span class="linenum">17</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">fails</span><span class="punct">"</span> <span class="keyword">do</span>
325
321
  <span class="offending"><span class="linenum">18</span> <span class="ident">pending</span> <span class="keyword">do</span></span>
326
322
  <span class="linenum">19</span> <span class="ident">expect</span><span class="punct">(</span><span class="number">1</span><span class="punct">).</span><span class="ident">to</span> <span class="ident">eq</span><span class="punct">(</span><span class="number">1</span><span class="punct">)</span>
327
323
  <span class="linenum">20</span> <span class="keyword">end</span></code></pre>
@@ -333,7 +329,9 @@ a {
333
329
  <dl style="margin-left: 0px;">
334
330
  <dt id="example_group_5" class="passed">passing spec</dt>
335
331
  <script type="text/javascript">moveProgressBar('57.1');</script>
336
- <dd class="example passed"><span class="passed_spec_name">passes</span><span class='duration'>n.nnnns</span></dd>
332
+ <dd class="example passed">
333
+ <span class="passed_spec_name">passes</span><span class="duration">n.nnnns</span>
334
+ </dd>
337
335
  </dl>
338
336
  </div>
339
337
  <div id="div_group_6" class="example_group passed">
@@ -352,12 +350,9 @@ expected: 2
352
350
 
353
351
  (compared using ==)
354
352
  </pre></div>
355
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33:in `(root)'
356
- ././spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
357
- ././spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
358
- ././spec/support/sandboxed_mock_space.rb:32:in `sandboxed'</pre></div>
359
- <pre class="ruby"><code><span class="linenum">31</span><span class="ident">describe</span> <span class="punct">&quot;</span><span class="string">failing spec</span><span class="punct">&quot;</span> <span class="keyword">do</span>
360
- <span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">fails</span><span class="punct">&quot;</span> <span class="keyword">do</span>
353
+ <div class="backtrace"><pre>&lt;a href="txmt://open?url=file</pre></div>
354
+ <pre class="ruby"><code><span class="linenum">31</span><span class="ident">describe</span> <span class="punct">"</span><span class="string">failing spec</span><span class="punct">"</span> <span class="keyword">do</span>
355
+ <span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">fails</span><span class="punct">"</span> <span class="keyword">do</span>
361
356
  <span class="offending"><span class="linenum">33</span> <span class="ident">expect</span><span class="punct">(</span><span class="number">1</span><span class="punct">).</span><span class="ident">to</span> <span class="ident">eq</span><span class="punct">(</span><span class="number">2</span><span class="punct">)</span></span>
362
357
  <span class="linenum">34</span> <span class="keyword">end</span>
363
358
  <span class="linenum">35</span><span class="keyword">end</span></code></pre>
@@ -376,11 +371,7 @@ expected: 2
376
371
  <span class="duration">n.nnnns</span>
377
372
  <div class="failure" id="failure_3">
378
373
  <div class="message"><pre>foo</pre></div>
379
- <div class="backtrace"><pre>(erb):1:in `result'
380
- ./spec/rspec/core/resources/formatter_specs.rb:41:in `(root)'
381
- ././spec/support/sandboxed_mock_space.rb:33:in `sandboxed'
382
- ././spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
383
- ././spec/support/sandboxed_mock_space.rb:32:in `sandboxed'</pre></div>
374
+ <div class="backtrace"><pre>&lt;a href="txmt://open?url=file</pre></div>
384
375
  <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
385
376
  </div>
386
377
  </dd>
@@ -390,7 +381,7 @@ expected: 2
390
381
  <span class="duration">n.nnnns</span>
391
382
  <div class="failure" id="failure_4">
392
383
  <div class="message"><pre>Exception</pre></div>
393
- <div class="backtrace"><pre>/foo.html.erb:1:in `&lt;main&gt;': foo (RuntimeError)</pre></div>
384
+ <div class="backtrace"><pre></pre></div>
394
385
  <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
395
386
  </div>
396
387
  </dd>
@@ -401,4 +392,7 @@ expected: 2
401
392
  </div>
402
393
  </div>
403
394
  </body>
404
- </html>
395
+ </html><html><p>
396
+
397
+ 2 deprecation warnings total
398
+ </p></html>
@@ -7,19 +7,10 @@ module RSpec
7
7
  module Core
8
8
  module Formatters
9
9
  describe TextMateFormatter do
10
- let(:suffix) {
11
- if ::RUBY_PLATFORM == 'java'
12
- "-jruby"
13
- elsif defined?(Rubinius)
14
- "-rbx"
15
- else
16
- ""
17
- end
18
- }
19
10
 
20
11
  let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
21
12
  let(:expected_file) do
22
- "#{File.dirname(__FILE__)}/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html"
13
+ "#{File.dirname(__FILE__)}/text_mate_formatted.html"
23
14
  end
24
15
 
25
16
  let(:generated_html) do
@@ -35,7 +26,20 @@ module RSpec
35
26
  command_line = RSpec::Core::CommandLine.new(options)
36
27
  command_line.instance_variable_get("@configuration").backtrace_cleaner.inclusion_patterns = []
37
28
  command_line.run(err, out)
38
- out.string.gsub(/\d+\.\d+(s| seconds)/, "n.nnnn\\1")
29
+ html = out.string.gsub(/\d+\.\d+(s| seconds)/, "n.nnnn\\1")
30
+
31
+ actual_doc = Nokogiri::HTML(html)
32
+ actual_doc.css("div.backtrace pre").each do |elem|
33
+ # This is to minimize churn on backtrace lines that we do not
34
+ # assert on anyway.
35
+ backtrace = elem.inner_html.lines.
36
+ select {|e| e =~ /formatter_specs\.rb/ }.
37
+ map {|x| x.chomp.split(":")[0..1].join(':') }.
38
+ join("\n")
39
+
40
+ elem.inner_html = backtrace
41
+ end
42
+ actual_doc.inner_html
39
43
  end
40
44
 
41
45
  let(:expected_html) do
@@ -61,33 +65,34 @@ module RSpec
61
65
  end
62
66
  end
63
67
 
64
- it "produces HTML identical to the one we designed manually" do
65
- Dir.chdir(root) do
66
- actual_doc = Nokogiri::HTML(generated_html)
67
- backtrace_lines = actual_doc.search("div.backtrace a")
68
- actual_doc.search("div.backtrace").remove
69
-
70
- expected_doc = Nokogiri::HTML(expected_html)
71
- expected_doc.search("div.backtrace").remove
72
-
73
- expect(actual_doc.inner_html).to eq(expected_doc.inner_html)
74
-
75
- backtrace_lines.each do |backtrace_line|
76
- expect(backtrace_line['href']).to include("txmt://open?url=")
77
- end
68
+ describe 'produced HTML', :if => RUBY_VERSION <= '2.0.0' do
69
+ # Rubies before 2 are a wild west of different outputs, and it's not
70
+ # worth the effort to maintain accurate fixtures for all of them.
71
+ # Since we are verifying fixtures on other rubies, if this code at
72
+ # least runs we can be reasonably confident the output is right since
73
+ # behaviour variances that we care about across versions is neglible.
74
+ it 'is present' do
75
+ expect(generated_html).to be
78
76
  end
79
77
  end
80
78
 
81
- it "has a backtrace line from the raw erb evaluation" do
82
- Dir.chdir(root) do
83
- actual_doc = Nokogiri::HTML(generated_html)
79
+ context 'produced HTML', :if => RUBY_VERSION >= '2.0.0' do
80
+ it "produces HTML identical to the one we designed manually" do
81
+ Dir.chdir(root) do
82
+ actual_doc = Nokogiri::HTML(generated_html)
83
+ backtrace_lines = actual_doc.search("div.backtrace a")
84
+ actual_doc.search("div.backtrace").remove
84
85
 
85
- expect(actual_doc.inner_html).to include('(erb):1')
86
- end
87
- end
86
+ expected_doc = Nokogiri::HTML(expected_html)
87
+ expected_doc.search("div.backtrace").remove
88
88
 
89
- it "has a backtrace line from a erb source file we forced to appear" do
90
- expect(generated_html).to include('open?url=file:///foo.html.erb')
89
+ expect(actual_doc.inner_html).to eq(expected_doc.inner_html)
90
+
91
+ backtrace_lines.each do |backtrace_line|
92
+ expect(backtrace_line['href']).to include("txmt://open?url=")
93
+ end
94
+ end
95
+ end
91
96
  end
92
97
 
93
98
  end