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
Line #Line
1Line 1
2Line 2
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 == "/action_controller/filters.rb:697:in `call_filters'" end it "converts html entities for non-stack trace lines" do line = %{escape me} html = @reporter.wrap_stack_trace_line(line) html.should == %{<a href="foo">escape me</a>} 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