Sha256: 4e17d2a2f25fbff56de1de6384e3a7b5a0b1770f422d60614380189feccdb5bc

Contents?: true

Size: 1.9 KB

Versions: 5

Compression:

Stored size: 1.9 KB

Contents

require File.join(File.dirname(__FILE__), "..", "..", "test_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="sort asc"><span>Line #</span><span class="sort"><em>&#8613;</em></span></th><th class="sort left"><span>Line</span><span class="sort"><em>&#8613;</em></span></th></tr></thead><tr><td>1</td><td>Line 1</td></tr><tr><td>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

5 entries across 5 versions & 2 rubygems

Version Path
relevance-tarantula-0.0.5 test/relevance/tarantula/html_report_helper_test.rb
relevance-tarantula-0.0.6 test/relevance/tarantula/html_report_helper_test.rb
relevance-tarantula-0.0.7.1 test/relevance/tarantula/html_report_helper_test.rb
relevance-tarantula-0.0.7 test/relevance/tarantula/html_report_helper_test.rb
tarantula-0.0.5 test/relevance/tarantula/html_report_helper_test.rb