diff --git a/capybara-screenshot.gemspec b/capybara-screenshot.gemspec index c7c0120..72c655d 100644 --- a/capybara-screenshot.gemspec +++ b/capybara-screenshot.gemspec @@ -21,7 +21,8 @@ Gem::Specification.new do |s| s.add_dependency 'capybara', ['>= 1.0', '< 3'] end s.add_dependency 'launchy' - + s.add_dependency 'colorize' + s.add_development_dependency 'rspec', '~> 2.7' s.add_development_dependency 'timecop' diff --git a/lib/capybara-screenshot/cucumber.rb b/lib/capybara-screenshot/cucumber.rb index b5f0e28..00d899c 100644 --- a/lib/capybara-screenshot/cucumber.rb +++ b/lib/capybara-screenshot/cucumber.rb @@ -4,6 +4,7 @@ saver = Capybara::Screenshot::Saver.new(Capybara, Capybara.page, true, filename_prefix) saver.save + saver.output_screenshot_path # Trying to embed the screenshot into our output." if File.exist?(saver.screenshot_path) @@ -15,4 +16,4 @@ embed("data:image/png;base64,#{encoded_img}", 'image/png', "Screenshot of the error") end end -end \ No newline at end of file +end diff --git a/lib/capybara-screenshot/minitest.rb b/lib/capybara-screenshot/minitest.rb index 109f7eb..cebb22b 100644 --- a/lib/capybara-screenshot/minitest.rb +++ b/lib/capybara-screenshot/minitest.rb @@ -16,9 +16,10 @@ saver = Capybara::Screenshot::Saver.new(Capybara, Capybara.page, true, filename_prefix) saver.save + saver.output_screenshot_path end end rescue NoMethodError # do nothing, teardown for minitest not available end -end \ No newline at end of file +end diff --git a/lib/capybara-screenshot/rspec/text_reporter.rb b/lib/capybara-screenshot/rspec/text_reporter.rb index 4fe97a7..4f5fb53 100644 --- a/lib/capybara-screenshot/rspec/text_reporter.rb +++ b/lib/capybara-screenshot/rspec/text_reporter.rb @@ -11,9 +11,8 @@ def dump_failure_info_with_screenshot(example) dump_failure_info_without_screenshot(example) return unless (screenshot = example.metadata[:screenshot]) - colorize = lambda { |str| respond_to?(:failure_color, true) ? failure_color(str) : red(str) } - output.puts(long_padding + colorize["HTML page: #{screenshot[:html]}"]) if screenshot[:html] - output.puts(long_padding + colorize["Screenshot: #{screenshot[:image]}"]) if screenshot[:image] + output.puts(long_padding + "HTML screenshot: #{screenshot[:html]}".colorize(:yellow)) if screenshot[:html] + output.puts(long_padding + "Image screenshot: #{screenshot[:image]}".colorize(:yellow)) if screenshot[:image] end end end diff --git a/lib/capybara-screenshot/saver.rb b/lib/capybara-screenshot/saver.rb index c420861..db63797 100644 --- a/lib/capybara-screenshot/saver.rb +++ b/lib/capybara-screenshot/saver.rb @@ -1,3 +1,5 @@ +require 'colorize' + module Capybara module Screenshot class Saver @@ -67,6 +69,11 @@ def clear_save_and_open_page_path yield Capybara.save_and_open_page_path = old_path end + + def output_screenshot_path + puts " #{"HTML screenshot: #{html_path}".colorize(:yellow)}" if html_saved? + puts " #{"Image screenshot: #{screenshot_path}".colorize(:yellow)}" if screenshot_saved? + end end end end diff --git a/lib/capybara-screenshot/spinach.rb b/lib/capybara-screenshot/spinach.rb index 1e6fd9f..aa3cd0d 100644 --- a/lib/capybara-screenshot/spinach.rb +++ b/lib/capybara-screenshot/spinach.rb @@ -3,5 +3,6 @@ filename_prefix = Capybara::Screenshot.filename_prefix_for(:spinach, step_data) saver = Capybara::Screenshot::Saver.new(Capybara, Capybara.page, true, filename_prefix) saver.save + saver.output_screenshot_path end -end \ No newline at end of file +end diff --git a/lib/capybara-screenshot/testunit.rb b/lib/capybara-screenshot/testunit.rb index 980422e..862ebb8 100644 --- a/lib/capybara-screenshot/testunit.rb +++ b/lib/capybara-screenshot/testunit.rb @@ -11,6 +11,7 @@ def notify_fault_with_screenshot(fault, *args) saver = Capybara::Screenshot::Saver.new(Capybara, Capybara.page, true, filename_prefix) saver.save + saver.output_screenshot_path end end end