Skip to content
This repository
Browse code

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

…he textmate formatter
  • Loading branch information...
commit 1863a2a975090853e57129ab44ef9d0e37a369f5 1 parent f78ff61
Alex Crichton authored September 24, 2010 dchelimsky committed October 14, 2010
91  spec/rspec/core/formatters/text_mate_formatted-1.9.2.html
@@ -184,7 +184,7 @@
184 184
   <dt id="example_group_1">pending spec with no implementation</dt>
185 185
     <script type="text/javascript">makeYellow('rspec-header');</script>
186 186
     <script type="text/javascript">makeYellow('example_group_1');</script>
187  
-    <script type="text/javascript">moveProgressBar('20.0');</script>
  187
+    <script type="text/javascript">moveProgressBar('14.2');</script>
188 188
     <dd class="spec not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: Not Yet Implemented)</span></dd>
189 189
   </dl>
190 190
 </div>
@@ -198,7 +198,7 @@
198 198
   <dt id="example_group_3">with content that would fail</dt>
199 199
     <script type="text/javascript">makeYellow('rspec-header');</script>
200 200
     <script type="text/javascript">makeYellow('example_group_3');</script>
201  
-    <script type="text/javascript">moveProgressBar('40.0');</script>
  201
+    <script type="text/javascript">moveProgressBar('28.5');</script>
202 202
     <dd class="spec not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: No reason given)</span></dd>
203 203
   </dl>
204 204
 </div>
@@ -207,22 +207,22 @@
207 207
   <dt id="example_group_4">with content that would pass</dt>
208 208
     <script type="text/javascript">makeRed('rspec-header');</script>
209 209
     <script type="text/javascript">makeRed('example_group_4');</script>
210  
-    <script type="text/javascript">moveProgressBar('60.0');</script>
  210
+    <script type="text/javascript">moveProgressBar('42.8');</script>
211 211
     <dd class="spec pending_fixed">
212 212
       <span class="failed_spec_name">fails</span>
213 213
       <div class="failure" id="failure_0">
214 214
         <div class="message"><pre>RSpec::Core::PendingExampleFixedError</pre></div>
215  
-        <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)>'
216  
-<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>'
217  
-<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>'
218  
-<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'
219  
-<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>'
220  
-<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'
221  
-<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>'
222  
-<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)>'
223  
-<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'
224  
-<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'
225  
-<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>
  215
+        <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)>'
  216
+<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>'
  217
+<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>'
  218
+<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'
  219
+<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>'
  220
+<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'
  221
+<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>'
  222
+<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)>'
  223
+<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'
  224
+<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'
  225
+<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>
226 226
     <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>
227 227
 <span class="linenum">12</span>          <span class="keyword">end</span>
228 228
 <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,7 +235,7 @@
235 235
 <div class="example_group">
236 236
   <dl>
237 237
   <dt id="example_group_5">passing spec</dt>
238  
-    <script type="text/javascript">moveProgressBar('80.0');</script>
  238
+    <script type="text/javascript">moveProgressBar('57.1');</script>
239 239
     <dd class="spec passed"><span class="passed_spec_name">passes</span></dd>
240 240
   </dl>
241 241
 </div>
@@ -243,7 +243,7 @@
243 243
   <dl>
244 244
   <dt id="example_group_6">failing spec</dt>
245 245
     <script type="text/javascript">makeRed('example_group_6');</script>
246  
-    <script type="text/javascript">moveProgressBar('100.0');</script>
  246
+    <script type="text/javascript">moveProgressBar('71.4');</script>
247 247
     <dd class="spec failed">
248 248
       <span class="failed_spec_name">fails</span>
249 249
       <div class="failure" id="failure_0">
@@ -253,17 +253,17 @@
253 253
 
254 254
 (compared using ==)
255 255
 </pre></div>
256  
-        <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)>'
257  
-<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>'
258  
-<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>'
259  
-<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'
260  
-<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>'
261  
-<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'
262  
-<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>'
263  
-<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)>'
264  
-<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'
265  
-<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'
266  
-<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>
  256
+        <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)>'
  257
+<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>'
  258
+<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>'
  259
+<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'
  260
+<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>'
  261
+<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'
  262
+<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>'
  263
+<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)>'
  264
+<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'
  265
+<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'
  266
+<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>
267 267
     <pre class="ruby"><code><span class="linenum">27</span>        <span class="keyword">end</span>
268 268
 <span class="linenum">28</span>
269 269
 <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 @@
272 272
     </dd>
273 273
   </dl>
274 274
 </div>
  275
+<div class="example_group">
  276
+  <dl>
  277
+  <dt id="example_group_7">a failing spec with odd backtraces</dt>
  278
+    <script type="text/javascript">makeRed('example_group_7');</script>
  279
+    <script type="text/javascript">moveProgressBar('85.7');</script>
  280
+    <dd class="spec failed">
  281
+      <span class="failed_spec_name">fails with a backtrace that has no file</span>
  282
+      <div class="failure" id="failure_0">
  283
+        <div class="message"><pre>foo</pre></div>
  284
+        <div class="backtrace"><pre>(erb):1:in `<main>'
  285
+<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)>'
  286
+<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>'
  287
+<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>'
  288
+<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'
  289
+<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>'
  290
+<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'
  291
+<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>'
  292
+<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)>'
  293
+<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'
  294
+<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'
  295
+<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>
  296
+    <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
  297
+      </div>
  298
+    </dd>
  299
+    <script type="text/javascript">moveProgressBar('100.0');</script>
  300
+    <dd class="spec failed">
  301
+      <span class="failed_spec_name">fails with a backtrace containing an erb file</span>
  302
+      <div class="failure" id="failure_0">
  303
+        <div class="message"><pre>Exception</pre></div>
  304
+        <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>
  305
+    <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
  306
+      </div>
  307
+    </dd>
  308
+  </dl>
  309
+</div>
275 310
 <script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script>
276  
-<script type="text/javascript">document.getElementById('totals').innerHTML = "5 examples, 2 failures, 2 pending";</script>
  311
+<script type="text/javascript">document.getElementById('totals').innerHTML = "7 examples, 4 failures, 2 pending";</script>
277 312
 </div>
278 313
 </div>
279 314
 </body>
14  spec/rspec/core/formatters/text_mate_formatter_spec.rb
@@ -23,6 +23,7 @@ module Formatters
23 23
           command_line = RSpec::Core::CommandLine.new(options)
24 24
           command_line.run(err, out)
25 25
           out.string.gsub /\d+\.\d+ seconds/, 'x seconds'
  26
+
26 27
         end
27 28
 
28 29
         let(:expected_html) do
@@ -64,6 +65,19 @@ module Formatters
64 65
             end
65 66
           end
66 67
         end
  68
+
  69
+        it "has a backtrace line from the raw erb evaluation" do
  70
+          Dir.chdir(root) do
  71
+            actual_doc = Nokogiri::HTML(generated_html)
  72
+
  73
+            actual_doc.inner_html.should include('(erb):1:in')
  74
+          end
  75
+        end
  76
+
  77
+        it "has a backtrace line from a erb source file we forced to appear" do
  78
+          generated_html.should include('open?url=file:///foo.html.erb')
  79
+        end
  80
+
67 81
       end
68 82
     end
69 83
   end
20  spec/rspec/core/resources/formatter_specs.rb
... ...
@@ -1,6 +1,5 @@
1 1
 # Deliberately named _specs.rb to avoid being loaded except when specified
2 2
 
3  
-
4 3
 describe "pending spec with no implementation" do
5 4
   it "is pending"
6 5
 end
@@ -34,3 +33,22 @@
34 33
     1.should eq(2)
35 34
   end
36 35
 end
  36
+
  37
+describe "a failing spec with odd backtraces" do
  38
+  it "fails with a backtrace that has no file" do
  39
+    require 'erb'
  40
+
  41
+    ERB.new("<%= raise 'foo' %>").result
  42
+  end
  43
+
  44
+  it "fails with a backtrace containing an erb file" do
  45
+    e = Exception.new
  46
+
  47
+    def e.backtrace
  48
+      ["/foo.html.erb:1:in `<main>': foo (RuntimeError)",
  49
+        "   from /lib/ruby/1.9.1/erb.rb:753:in `eval'"]
  50
+    end
  51
+
  52
+    raise e
  53
+  end
  54
+end

0 notes on commit 1863a2a

Please sign in to comment.
Something went wrong with that request. Please try again.