Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 7009c33

Browse files
committed
Remove nokogiri development dependency
1 parent 427e765 commit 7009c33

File tree

3 files changed

+78
-86
lines changed

3 files changed

+78
-86
lines changed

rspec-core.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Gem::Specification.new do |s|
4242
s.add_development_dependency "minitest", "~> 5.3"
4343
s.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7
4444

45-
s.add_development_dependency "nokogiri", (RUBY_VERSION < '1.9.3' ? "1.5.2" : ["~> 1.5", "!= 1.6.6.3", "!= 1.6.6.4", "!= 1.6.7.1", "!= 1.6.7"])
4645
s.add_development_dependency "coderay", "~> 1.0.9"
4746

4847
s.add_development_dependency "mocha", "~> 0.13.0"

spec/rspec/core/formatters/html_formatted.html

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
<html lang="en">
1+
<!DOCTYPE html>
2+
<html lang='en'>
23
<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">
4+
<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" />
8+
<style type="text/css">
89
body {
910
margin: 0;
1011
padding: 0;
1112
background: #fff;
1213
font-size: 80%;
1314
}
1415
</style>
15-
<script type="text/javascript">
16+
<script type="text/javascript">
1617
// <![CDATA[
1718

1819
function addClass(element_id, classname) {
@@ -90,7 +91,8 @@
9091
}
9192

9293
// ]]>
93-
</script><style type="text/css">
94+
</script>
95+
<style type="text/css">
9496
#rspec-header {
9597
background: #65C400; color: #fff; height: 4em;
9698
}
@@ -264,48 +266,60 @@ <h1>RSpec Code Examples</h1>
264266
</div>
265267

266268
<div id="display-filters">
267-
<input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked onchange="apply_filters()" value="1"><label for="passed_checkbox">Passed</label>
268-
<input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked onchange="apply_filters()" value="2"><label for="failed_checkbox">Failed</label>
269-
<input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked onchange="apply_filters()" value="3"><label for="pending_checkbox">Pending</label>
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>
270272
</div>
271273

272274
<div id="summary">
273-
<p id="totals"> </p>
274-
<p id="duration"> </p>
275+
<p id="totals">&#160;</p>
276+
<p id="duration">&#160;</p>
275277
</div>
276278
</div>
277279

278280

279281
<div class="results">
280282
<div id="div_group_1" class="example_group passed">
281283
<dl style="margin-left: 0px;">
282-
<dt id="example_group_1" class="passed">pending spec with no implementation</dt>
283-
<script type="text/javascript">makeYellow('rspec-header');</script><script type="text/javascript">makeYellow('div_group_1');</script><script type="text/javascript">makeYellow('example_group_1');</script><script type="text/javascript">moveProgressBar('12.5');</script><dd class="example not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: Not yet implemented)</span></dd>
284+
<dt id="example_group_1" class="passed">pending spec with no implementation</dt>
285+
<script type="text/javascript">makeYellow('rspec-header');</script>
286+
<script type="text/javascript">makeYellow('div_group_1');</script>
287+
<script type="text/javascript">makeYellow('example_group_1');</script>
288+
<script type="text/javascript">moveProgressBar('12.5');</script>
289+
<dd class="example not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: Not yet implemented)</span></dd>
284290
</dl>
285291
</div>
286292
<div id="div_group_2" class="example_group passed">
287293
<dl style="margin-left: 0px;">
288-
<dt id="example_group_2" class="passed">pending command with block format</dt>
294+
<dt id="example_group_2" class="passed">pending command with block format</dt>
289295
</dl>
290296
</div>
291297
<div id="div_group_3" class="example_group passed">
292298
<dl style="margin-left: 15px;">
293-
<dt id="example_group_3" class="passed">with content that would fail</dt>
294-
<script type="text/javascript">makeYellow('rspec-header');</script><script type="text/javascript">makeYellow('div_group_3');</script><script type="text/javascript">makeYellow('example_group_3');</script><script type="text/javascript">moveProgressBar('25.0');</script><dd class="example not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: No reason given)</span></dd>
299+
<dt id="example_group_3" class="passed">with content that would fail</dt>
300+
<script type="text/javascript">makeYellow('rspec-header');</script>
301+
<script type="text/javascript">makeYellow('div_group_3');</script>
302+
<script type="text/javascript">makeYellow('example_group_3');</script>
303+
<script type="text/javascript">moveProgressBar('25.0');</script>
304+
<dd class="example not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: No reason given)</span></dd>
295305
</dl>
296306
</div>
297307
<div id="div_group_4" class="example_group passed">
298308
<dl style="margin-left: 15px;">
299-
<dt id="example_group_4" class="passed">behaves like shared</dt>
300-
<script type="text/javascript">makeRed('rspec-header');</script><script type="text/javascript">makeRed('div_group_4');</script><script type="text/javascript">makeRed('example_group_4');</script><script type="text/javascript">moveProgressBar('37.5');</script><dd class="example pending_fixed">
309+
<dt id="example_group_4" class="passed">behaves like shared</dt>
310+
<script type="text/javascript">makeRed('rspec-header');</script>
311+
<script type="text/javascript">makeRed('div_group_4');</script>
312+
<script type="text/javascript">makeRed('example_group_4');</script>
313+
<script type="text/javascript">moveProgressBar('37.5');</script>
314+
<dd class="example pending_fixed">
301315
<span class="failed_spec_name">is marked as pending but passes</span>
302316
<span class="duration">n.nnnns</span>
303317
<div class="failure" id="failure_1">
304318
<div class="message"><pre>Expected example to fail since it is pending, but it passed.</pre></div>
305319
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:4</pre></div>
306320
<pre class="ruby"><code><span class="linenum">2</span>
307-
<span class="linenum">3</span><span class="constant">RSpec</span>.shared_examples_for <span class="string"><span class="delimiter">"</span><span class="content">shared</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
308-
<span class="offending"><span class="linenum">4</span> it <span class="string"><span class="delimiter">"</span><span class="content">is marked as pending but passes</span><span class="delimiter">"</span></span> <span class="keyword">do</span></span>
321+
<span class="linenum">3</span><span class="constant">RSpec</span>.shared_examples_for <span class="string"><span class="delimiter">&quot;</span><span class="content">shared</span><span class="delimiter">&quot;</span></span> <span class="keyword">do</span>
322+
<span class="offending"><span class="linenum">4</span> it <span class="string"><span class="delimiter">&quot;</span><span class="content">is marked as pending but passes</span><span class="delimiter">&quot;</span></span> <span class="keyword">do</span></span>
309323
<span class="linenum">5</span> pending
310324
<span class="linenum">6</span> expect(<span class="integer">1</span>).to eq(<span class="integer">1</span>)</code></pre>
311325
</div>
@@ -314,16 +328,18 @@ <h1>RSpec Code Examples</h1>
314328
</div>
315329
<div id="div_group_5" class="example_group passed">
316330
<dl style="margin-left: 0px;">
317-
<dt id="example_group_5" class="passed">passing spec</dt>
318-
<script type="text/javascript">moveProgressBar('50.0');</script><dd class="example passed">
319-
<span class="passed_spec_name">passes</span><span class="duration">n.nnnns</span>
320-
</dd>
331+
<dt id="example_group_5" class="passed">passing spec</dt>
332+
<script type="text/javascript">moveProgressBar('50.0');</script>
333+
<dd class="example passed"><span class="passed_spec_name">passes</span><span class='duration'>n.nnnns</span></dd>
321334
</dl>
322335
</div>
323336
<div id="div_group_6" class="example_group passed">
324337
<dl style="margin-left: 0px;">
325-
<dt id="example_group_6" class="passed">failing spec</dt>
326-
<script type="text/javascript">makeRed('div_group_6');</script><script type="text/javascript">makeRed('example_group_6');</script><script type="text/javascript">moveProgressBar('62.5');</script><dd class="example failed">
338+
<dt id="example_group_6" class="passed">failing spec</dt>
339+
<script type="text/javascript">makeRed('div_group_6');</script>
340+
<script type="text/javascript">makeRed('example_group_6');</script>
341+
<script type="text/javascript">moveProgressBar('62.5');</script>
342+
<dd class="example failed">
327343
<span class="failed_spec_name">fails</span>
328344
<span class="duration">n.nnnns</span>
329345
<div class="failure" id="failure_2">
@@ -333,9 +349,9 @@ <h1>RSpec Code Examples</h1>
333349

334350
(compared using ==)
335351
</pre></div>
336-
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33</pre></div>
337-
<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>
338-
<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>
352+
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33:in `block (2 levels) in &lt;top (required)&gt;&#39;</pre></div>
353+
<pre class="ruby"><code><span class="linenum">31</span><span class="constant">RSpec</span>.describe <span class="string"><span class="delimiter">&quot;</span><span class="content">failing spec</span><span class="delimiter">&quot;</span></span> <span class="keyword">do</span>
354+
<span class="linenum">32</span> it <span class="string"><span class="delimiter">&quot;</span><span class="content">fails</span><span class="delimiter">&quot;</span></span> <span class="keyword">do</span>
339355
<span class="offending"><span class="linenum">33</span> expect(<span class="integer">1</span>).to eq(<span class="integer">2</span>)</span>
340356
<span class="linenum">34</span> <span class="keyword">end</span>
341357
<span class="linenum">35</span><span class="keyword">end</span></code></pre>
@@ -345,17 +361,21 @@ <h1>RSpec Code Examples</h1>
345361
</div>
346362
<div id="div_group_7" class="example_group passed">
347363
<dl style="margin-left: 0px;">
348-
<dt id="example_group_7" class="passed">a failing spec with odd backtraces</dt>
349-
<script type="text/javascript">makeRed('div_group_7');</script><script type="text/javascript">makeRed('example_group_7');</script><script type="text/javascript">moveProgressBar('75.0');</script><dd class="example failed">
364+
<dt id="example_group_7" class="passed">a failing spec with odd backtraces</dt>
365+
<script type="text/javascript">makeRed('div_group_7');</script>
366+
<script type="text/javascript">makeRed('example_group_7');</script>
367+
<script type="text/javascript">moveProgressBar('75.0');</script>
368+
<dd class="example failed">
350369
<span class="failed_spec_name">fails with a backtrace that has no file</span>
351370
<span class="duration">n.nnnns</span>
352371
<div class="failure" id="failure_3">
353372
<div class="message"><pre>foo</pre></div>
354-
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:41</pre></div>
373+
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:41:in `block (2 levels) in &lt;top (required)&gt;&#39;</pre></div>
355374
<pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
356375
</div>
357376
</dd>
358-
<script type="text/javascript">moveProgressBar('87.5');</script><dd class="example failed">
377+
<script type="text/javascript">moveProgressBar('87.5');</script>
378+
<dd class="example failed">
359379
<span class="failed_spec_name">fails with a backtrace containing an erb file</span>
360380
<span class="duration">n.nnnns</span>
361381
<div class="failure" id="failure_4">
@@ -368,8 +388,11 @@ <h1>RSpec Code Examples</h1>
368388
</div>
369389
<div id="div_group_8" class="example_group passed">
370390
<dl style="margin-left: 15px;">
371-
<dt id="example_group_8" class="passed">with a `nil` backtrace</dt>
372-
<script type="text/javascript">makeRed('div_group_8');</script><script type="text/javascript">makeRed('example_group_8');</script><script type="text/javascript">moveProgressBar('100.0');</script><dd class="example failed">
391+
<dt id="example_group_8" class="passed">with a `nil` backtrace</dt>
392+
<script type="text/javascript">makeRed('div_group_8');</script>
393+
<script type="text/javascript">makeRed('example_group_8');</script>
394+
<script type="text/javascript">moveProgressBar('100.0');</script>
395+
<dd class="example failed">
373396
<span class="failed_spec_name">raises</span>
374397
<span class="duration">n.nnnns</span>
375398
<div class="failure" id="failure_5">
@@ -380,8 +403,9 @@ <h1>RSpec Code Examples</h1>
380403
</dd>
381404
</dl>
382405
</div>
383-
<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>n.nnnn seconds</strong>";</script><script type="text/javascript">document.getElementById('totals').innerHTML = "8 examples, 5 failures, 2 pending";</script>
406+
<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>n.nnnn seconds</strong>";</script>
407+
<script type="text/javascript">document.getElementById('totals').innerHTML = "8 examples, 5 failures, 2 pending";</script>
384408
</div>
385409
</div>
386410
</body>
387-
</html>
411+
</html>

spec/rspec/core/formatters/html_formatter_spec.rb

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
# encoding: utf-8
22
require 'rspec/core/formatters/html_formatter'
33

4-
# For some reason we get load errors when loading nokogiri on AppVeyor
5-
# on Ruby 2.1. On 1.9.3 it works just fine. No idea why.
6-
require 'nokogiri' unless ENV['APPVEYOR'] && RUBY_VERSION.to_f >= 2.1
7-
84
module RSpec
95
module Core
106
module Formatters
117
RSpec.describe HtmlFormatter, :failing_on_appveyor => (RUBY_VERSION.to_f >= 2.1) do
128
include FormatterSupport
139

1410
let(:root) { File.expand_path("#{File.dirname(__FILE__)}/../../../..") }
11+
1512
let(:expected_file) do
1613
"#{File.dirname(__FILE__)}/html_formatted.html"
1714
end
1815

19-
let(:generated_html) do
20-
html = run_example_specs_with_formatter('html')
21-
22-
actual_doc = Nokogiri::HTML(html, &:noblanks)
23-
actual_doc.css("div.backtrace pre").each do |elem|
24-
# This is to minimize churn on backtrace lines that we do not
25-
# assert on anyway.
26-
backtrace = elem.inner_html.lines.
27-
select {|e| e =~ /formatter_specs\.rb/ }.
28-
map {|x| x.chomp.split(":")[0..1].join(':') }.
29-
join("\n")
30-
31-
elem.inner_html = backtrace
32-
end
33-
actual_doc.inner_html
16+
let(:actual_html) do
17+
run_example_specs_with_formatter('html')
3418
end
3519

3620
let(:expected_html) do
@@ -41,14 +25,20 @@ module Formatters
4125
allow(RSpec.configuration).to receive(:load_spec_files) do
4226
RSpec.configuration.files_to_run.map {|f| load File.expand_path(f) }
4327
end
28+
29+
# This is to minimize churn on backtrace lines
30+
allow_any_instance_of(Notifications::FailedExampleNotification).
31+
to receive(:formatted_backtrace).and_wrap_original do |original_method|
32+
original_method.call.grep(/formatter_specs\.rb/)
33+
end
4434
end
4535

4636
# Uncomment this group temporarily in order to overwrite the expected
4737
# with actual. Use with care!!!
4838
describe "file generator", :if => ENV['GENERATE'] do
4939
it "generates a new comparison file" do
5040
Dir.chdir(root) do
51-
File.open(expected_file, 'w') {|io| io.write(generated_html)}
41+
File.open(expected_file, 'w') {|io| io.write(actual_html)}
5242
end
5343
end
5444
end
@@ -67,43 +57,22 @@ def extract_backtrace_from(doc)
6757
# least runs we can be reasonably confident the output is right since
6858
# behaviour variances that we care about across versions is neglible.
6959
it 'is present' do
70-
expect(generated_html).to be
60+
expect(actual_html).to be
7161
end
7262
end
7363

7464
describe 'produced HTML', :slow, :if => RUBY_VERSION >= '2.0.0' do
75-
def build_and_verify_formatter_output
76-
Dir.chdir(root) do
77-
actual_doc = Nokogiri::HTML(generated_html, &:noblanks)
78-
actual_backtraces = extract_backtrace_from(actual_doc)
79-
actual_doc.css("div.backtrace").remove
80-
81-
expected_doc = Nokogiri::HTML(expected_html, &:noblanks)
82-
expected_backtraces = extract_backtrace_from(expected_doc)
83-
expected_doc.search("div.backtrace").remove
84-
85-
expect(actual_doc.inner_html).to eq(expected_doc.inner_html)
86-
87-
expected_backtraces.each_with_index do |expected_line, i|
88-
expected_path, expected_line_number, expected_suffix = expected_line.split(':')
89-
actual_path, actual_line_number, actual_suffix = actual_backtraces[i].split(':')
90-
91-
expect(File.expand_path(actual_path)).to eq(File.expand_path(expected_path))
92-
expect(actual_line_number).to eq(expected_line_number)
93-
expect(actual_suffix).to eq(expected_suffix)
94-
end
95-
end
96-
end
97-
9865
it "is identical to the one we designed manually", :pending => (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby') do
99-
build_and_verify_formatter_output
66+
expect(actual_html).to eq(expected_html)
10067
end
10168

10269
context 'with mathn loaded' do
10370
include MathnIntegrationSupport
10471

10572
it "is identical to the one we designed manually", :slow, :pending => (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby') do
106-
with_mathn_loaded { build_and_verify_formatter_output }
73+
with_mathn_loaded do
74+
expect(actual_html).to eq(expected_html)
75+
end
10776
end
10877
end
10978
end

0 commit comments

Comments
 (0)