Sha256: 21845cf7d3c971f8edca6b9049d52ad4a8d2db80824fa0181a0c6a502f307f09

Contents?: true

Size: 1.87 KB

Versions: 6

Compression:

Stored size: 1.87 KB

Contents

require File.join(File.dirname(__FILE__), "..", "..", "example_helper.rb")

module HtmlReportHelperSpec
  # Is there an idiom for this?
  def self.included(base)
    base.before do
      @reporter = Object.new
      @reporter.extend Relevance::Tarantula::HtmlReportHelper
    end                                                                   
  end 
end

describe 'Relevance::Tarantula::HtmlReportHelper#wrap_in_line_number_table' do
  include HtmlReportHelperSpec
  it "can wrap text in a line number table" do
    html = @reporter.wrap_in_line_number_table("Line 1\nLine 2")
    html.should == <<-END.strip
<table class=\"grid tablesorter\"><thead><tr><th class=\"line-number\"><span>Line #</span></th><th align=\"center\"><span>Line</span></th></tr></thead><tr><td class=\"line-number\">1</td><td>Line 1</td></tr><tr><td class=\"line-number\">2</td><td>Line 2</td></tr></table>
END
  end  
end

describe 'Relevance::Tarantula::HtmlReportHelper#wrap_stack_trace_line' do
  include HtmlReportHelperSpec
  it "can wrap stack trace line in links" do                       
    line = %{/action_controller/filters.rb:697:in `call_filters'}
    @reporter.stubs(:textmate_url).returns("ide_url")
    html = @reporter.wrap_stack_trace_line(line)
    html.should == "<a href='ide_url'>/action_controller/filters.rb:697</a>:in `call_filters'"
  end  
  
  it "converts html entities for non-stack trace lines" do
    line = %{<a href="foo">escape me</a>}
    html = @reporter.wrap_stack_trace_line(line)
    html.should == %{&lt;a href=&quot;foo&quot;&gt;escape me&lt;/a&gt;}
  end

end

describe 'Relevance::Tarantula::HtmlReportHelper IDE help' do
  include HtmlReportHelperSpec
  it "can create a textmate url" do
    @reporter.stubs(:rails_root).returns("STUB_RAILS_ROOT")
    @reporter.textmate_url("/etc/somewhere", 100).should =~ %r{txmt://open\?url=.*/STUB_RAILS_ROOT/etc/somewhere&line_no=100}
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
relevance-tarantula-0.1.0 examples/relevance/tarantula/html_report_helper_example.rb
relevance-tarantula-0.1.1 examples/relevance/tarantula/html_report_helper_example.rb
relevance-tarantula-0.1.2 examples/relevance/tarantula/html_report_helper_example.rb
relevance-tarantula-0.1.3 examples/relevance/tarantula/html_report_helper_example.rb
relevance-tarantula-0.1.4 examples/relevance/tarantula/html_report_helper_example.rb
tarantula-0.1.4 examples/relevance/tarantula/html_report_helper_example.rb