Permalink
Browse files

Added tests for making sure erb files/evaluations don't drop out of t…

…he textmate formatter
  • Loading branch information...
1 parent f78ff61 commit 1863a2a975090853e57129ab44ef9d0e37a369f5 @alexcrichton alexcrichton committed with dchelimsky Sep 24, 2010
@@ -184,7 +184,7 @@
<dt id="example_group_1">pending spec with no implementation</dt>
<script type="text/javascript">makeYellow('rspec-header');</script>
<script type="text/javascript">makeYellow('example_group_1');</script>
- <script type="text/javascript">moveProgressBar('20.0');</script>
+ <script type="text/javascript">moveProgressBar('14.2');</script>
<dd class="spec not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: Not Yet Implemented)</span></dd>
</dl>
</div>
@@ -198,7 +198,7 @@
<dt id="example_group_3">with content that would fail</dt>
<script type="text/javascript">makeYellow('rspec-header');</script>
<script type="text/javascript">makeYellow('example_group_3');</script>
- <script type="text/javascript">moveProgressBar('40.0');</script>
+ <script type="text/javascript">moveProgressBar('28.5');</script>
<dd class="spec not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: No reason given)</span></dd>
</dl>
</div>
@@ -207,22 +207,22 @@
<dt id="example_group_4">with content that would pass</dt>
<script type="text/javascript">makeRed('rspec-header');</script>
<script type="text/javascript">makeRed('example_group_4');</script>
- <script type="text/javascript">moveProgressBar('60.0');</script>
+ <script type="text/javascript">moveProgressBar('42.8');</script>
<dd class="spec pending_fixed">
<span class="failed_spec_name">fails</span>
<div class="failure" id="failure_0">
<div class="message"><pre>RSpec::Core::PendingExampleFixedError</pre></div>
- <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=19">./spec/rspec/core/resources/formatter_specs.rb:19</a> :in `block (3 levels) in <top (required)>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=23">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:23</a> :in `block (2 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=43">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:43</a> :in `block (5 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=43">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:43</a> :in `open'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=43">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:43</a> :in `block (4 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=42">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:42</a> :in `chdir'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=42">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:42</a> :in `block (3 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=70">./spec/spec_helper.rb:70</a> :in `block (3 levels) in <top (required)>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=46">./spec/spec_helper.rb:46</a> :in `instance_eval'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=46">./spec/spec_helper.rb:46</a> :in `sandboxed'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=70">./spec/spec_helper.rb:70</a> :in `block (2 levels) in <top (required)>'</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=19">./spec/rspec/core/resources/formatter_specs.rb:19</a> :in `block (3 levels) in <top (required)>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `open'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=71">./spec/spec_helper.rb:71</a> :in `block (3 levels) in <top (required)>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=45">./spec/spec_helper.rb:45</a> :in `instance_eval'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=45">./spec/spec_helper.rb:45</a> :in `sandboxed'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=71">./spec/spec_helper.rb:71</a> :in `block (2 levels) in <top (required)>'</pre></div>
<pre class="ruby"><code><span class="linenum">11</span> <span class="keyword">rescue</span> <span class="constant">Exception</span> <span class="punct">=&gt;</span> <span class="ident">e</span>
<span class="linenum">12</span> <span class="keyword">end</span>
<span class="offending"><span class="linenum">13</span> <span class="keyword">raise</span> <span class="constant">RSpec</span><span class="punct">::</span><span class="constant">Core</span><span class="punct">::</span><span class="constant">PendingExampleFixedError</span><span class="punct">.</span><span class="ident">new</span> <span class="keyword">if</span> <span class="ident">result</span></span>
@@ -235,15 +235,15 @@
<div class="example_group">
<dl>
<dt id="example_group_5">passing spec</dt>
- <script type="text/javascript">moveProgressBar('80.0');</script>
+ <script type="text/javascript">moveProgressBar('57.1');</script>
<dd class="spec passed"><span class="passed_spec_name">passes</span></dd>
</dl>
</div>
<div class="example_group">
<dl>
<dt id="example_group_6">failing spec</dt>
<script type="text/javascript">makeRed('example_group_6');</script>
- <script type="text/javascript">moveProgressBar('100.0');</script>
+ <script type="text/javascript">moveProgressBar('71.4');</script>
<dd class="spec failed">
<span class="failed_spec_name">fails</span>
<div class="failure" id="failure_0">
@@ -253,17 +253,17 @@
(compared using ==)
</pre></div>
- <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=34">./spec/rspec/core/resources/formatter_specs.rb:34</a> :in `block (2 levels) in <top (required)>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=23">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:23</a> :in `block (2 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=43">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:43</a> :in `block (5 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=43">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:43</a> :in `open'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=43">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:43</a> :in `block (4 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=42">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:42</a> :in `chdir'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=42">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:42</a> :in `block (3 levels) in <module:Formatters>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=70">./spec/spec_helper.rb:70</a> :in `block (3 levels) in <top (required)>'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=46">./spec/spec_helper.rb:46</a> :in `instance_eval'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=46">./spec/spec_helper.rb:46</a> :in `sandboxed'
-<a href="txmt://open?url=file:///Users/dchelimsky/projects/ruby/rspec2/repos/rspec-core/spec/spec_helper.rb&line=70">./spec/spec_helper.rb:70</a> :in `block (2 levels) in <top (required)>'</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=34">./spec/rspec/core/resources/formatter_specs.rb:34</a> :in `block (2 levels) in <top (required)>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `open'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=71">./spec/spec_helper.rb:71</a> :in `block (3 levels) in <top (required)>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=45">./spec/spec_helper.rb:45</a> :in `instance_eval'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=45">./spec/spec_helper.rb:45</a> :in `sandboxed'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=71">./spec/spec_helper.rb:71</a> :in `block (2 levels) in <top (required)>'</pre></div>
<pre class="ruby"><code><span class="linenum">27</span> <span class="keyword">end</span>
<span class="linenum">28</span>
<span class="offending"><span class="linenum">29</span> <span class="keyword">raise</span><span class="punct">(</span><span class="constant">RSpec</span><span class="punct">::</span><span class="constant">Expectations</span><span class="punct">::</span><span class="constant">ExpectationNotMetError</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="ident">message</span><span class="punct">))</span></span>
@@ -272,8 +272,43 @@
</dd>
</dl>
</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_7">a failing spec with odd backtraces</dt>
+ <script type="text/javascript">makeRed('example_group_7');</script>
+ <script type="text/javascript">moveProgressBar('85.7');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">fails with a backtrace that has no file</span>
+ <div class="failure" id="failure_0">
+ <div class="message"><pre>foo</pre></div>
+ <div class="backtrace"><pre>(erb):1:in `<main>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=42">./spec/rspec/core/resources/formatter_specs.rb:42</a> :in `block (2 levels) in <top (required)>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `open'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in <module:Formatters>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=71">./spec/spec_helper.rb:71</a> :in `block (3 levels) in <top (required)>'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=45">./spec/spec_helper.rb:45</a> :in `instance_eval'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=45">./spec/spec_helper.rb:45</a> :in `sandboxed'
+<a href="txmt://open?url=file:///Users/alex/code/ruby/rspec-core/spec/spec_helper.rb&line=71">./spec/spec_helper.rb:71</a> :in `block (2 levels) in <top (required)>'</pre></div>
+ <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
+ </div>
+ </dd>
+ <script type="text/javascript">moveProgressBar('100.0');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">fails with a backtrace containing an erb file</span>
+ <div class="failure" id="failure_0">
+ <div class="message"><pre>Exception</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///foo.html.erb&line=1">/foo.html.erb:1</a> :in `<main>': foo (RuntimeError)</pre></div>
+ <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
+ </div>
+ </dd>
+ </dl>
+</div>
<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script>
-<script type="text/javascript">document.getElementById('totals').innerHTML = "5 examples, 2 failures, 2 pending";</script>
+<script type="text/javascript">document.getElementById('totals').innerHTML = "7 examples, 4 failures, 2 pending";</script>
</div>
</div>
</body>
@@ -23,6 +23,7 @@ module Formatters
command_line = RSpec::Core::CommandLine.new(options)
command_line.run(err, out)
out.string.gsub /\d+\.\d+ seconds/, 'x seconds'
+
end
let(:expected_html) do
@@ -64,6 +65,19 @@ module Formatters
end
end
end
+
+ it "has a backtrace line from the raw erb evaluation" do
+ Dir.chdir(root) do
+ actual_doc = Nokogiri::HTML(generated_html)
+
+ actual_doc.inner_html.should include('(erb):1:in')
+ end
+ end
+
+ it "has a backtrace line from a erb source file we forced to appear" do
+ generated_html.should include('open?url=file:///foo.html.erb')
+ end
+
end
end
end
@@ -1,6 +1,5 @@
# Deliberately named _specs.rb to avoid being loaded except when specified
-
describe "pending spec with no implementation" do
it "is pending"
end
@@ -34,3 +33,22 @@
1.should eq(2)
end
end
+
+describe "a failing spec with odd backtraces" do
+ it "fails with a backtrace that has no file" do
+ require 'erb'
+
+ ERB.new("<%= raise 'foo' %>").result
+ end
+
+ it "fails with a backtrace containing an erb file" do
+ e = Exception.new
+
+ def e.backtrace
+ ["/foo.html.erb:1:in `<main>': foo (RuntimeError)",
+ " from /lib/ruby/1.9.1/erb.rb:753:in `eval'"]
+ end
+
+ raise e
+ end
+end

0 comments on commit 1863a2a

Please sign in to comment.