Module: Capybara::Screenshot::RSpec::HtmlLinkReporter
- Extended by:
- BaseReporter
- Included in:
- TextMateLinkReporter
- Defined in:
- lib/capybara-screenshot/rspec/html_link_reporter.rb
Instance Method Summary collapse
- #attributes_for_screenshot_link(url) ⇒ Object
- #extra_failure_content_with_screenshot(exception) ⇒ Object
- #link_to_screenshot(title, path) ⇒ Object
Methods included from BaseReporter
Instance Method Details
#attributes_for_screenshot_link(url) ⇒ Object
31 32 33 |
# File 'lib/capybara-screenshot/rspec/html_link_reporter.rb', line 31 def attributes_for_screenshot_link(url) {"href" => url, "style" => "margin-right: 10px; font-weight: bold"} end |
#extra_failure_content_with_screenshot(exception) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/capybara-screenshot/rspec/html_link_reporter.rb', line 12 def extra_failure_content_with_screenshot(exception) result = extra_failure_content_without_screenshot(exception) example = @failed_examples.last if (screenshot = example.[:screenshot]) result << "<p>Saved files: " result << link_to_screenshot("HTML page", screenshot[:html]) if screenshot[:html] result << link_to_screenshot("Screenshot", screenshot[:image]) if screenshot[:image] result << "</p>" end result end |
#link_to_screenshot(title, path) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/capybara-screenshot/rspec/html_link_reporter.rb', line 24 def link_to_screenshot(title, path) url = URI.escape("file://#{path}") title = CGI.escape_html(title) attributes = attributes_for_screenshot_link(url).map { |name, val| %{#{name}="#{CGI.escape_html(val)}"} }.join(" ") "<a #{attributes}>#{title}</a>" end |