Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


using HtmlFormatter shows RSpec's internal snippet in the report #214

jarmo opened this Issue · 6 comments

4 participants


This line will be shown as a failing line in the report:

This is one sample of such a report:

I can reproduce it like this:

# some_spec.rb 
describe "something" do 
  it "doesn't work" do 
    true.should be_false 

C:\Users\jarmo\Desktop\minu\projects\Ruby\blah2>rspec some_spec.rb -f html -o out.html

This is the stack with -b:

c:/ruby/lib/ruby/gems/1.8/gems/rspec-expectations-2.0.1/lib/rspec/expectations/fail_with.rb:29:in `fail_with' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-expectations-2.0.1/lib/rspec/expectations/handler.rb:21:in `handle_matcher' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-expectations-2.0.1/lib/rspec/expectations/extensions/kernel.rb:27:in `should' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:47:in `instance_eval' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:47:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:86:in `call' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:86:in `with_around_hooks' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:44:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:80:in `call' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:80:in `with_pending_capture' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:79:in `catch' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:79:in `with_pending_capture' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example.rb:43:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example_group.rb:260:in `run_examples' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example_group.rb:256:in `map' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example_group.rb:256:in `run_examples' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/example_group.rb:230:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:26:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:26:in `map' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:26:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/reporter.rb:11:in `report' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:23:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:55:in `run_in_process' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:46:in `run' 
c:/ruby/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:10:in `autorun' 

It looks like format_backtrace is not called on the error's backtrace. So the backtrace is never cleaned. The SnippetExtractor takes an error in as an argument and pulls the backtrace from there. It then does not have access to the format_backtrace method. It looks like SnippetExtractor could be written to take a backtrace instead.


I have a fix but it maybe messing up textmate_formatter's open file links. I do not own a mac so I am not sure what they should be like. But I have a fix for this that fixes the snippets for both textmate and html formatters.




Any plan to merge these changes in? Are these made even into pull requests?


These changes seem to be working for me so far. Any plan to merge into master so i could remove these lines from my gem? :)


Hate to write just +1, but it is a major headpain, can you fix this? pretty please with sugar on?

@dchelimsky dchelimsky closed this in 68d51bb

Sorry this took so long to get to, but it's in now and will be part of the next release.

@scrummyin, the html fix was good so I merged your commit for that. The textmate fix was close but not quite, so I ended up rolling my own on that. Let me know if you have any questions.

@dchelimsky dchelimsky referenced this issue from a commit
@dchelimsky dchelimsky Changelog for #214 e666dd1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.