module Capybara::Differ
Constants
- VERSION
Public Instance Methods
check_page(name, options = {})
click to toggle source
# File lib/capybara-differ.rb, line 74 def check_page(name, options = {}) raise ArgumentError, 'options must be hash' unless options.is_a?(Hash) path_from_name = name.gsub(/[^a-z0-9\-_]+/i, '_') filename = File.join(path_from_name, Time.now.strftime('%Y%m%d%H%M%S') + '.html') save_page(filename) base_dir = File.join([Capybara.save_path, path_from_name].compact) file_list = Dir[File.join(base_dir, '*.html')].sort old_html_path = options[:compare_with] == :previous ? file_list[-2] : file_list.first new_html_path = file_list.last comparator = Capybara::Differ::Comparator.new(old_html_path, new_html_path, options) if (result = comparator.compare).strip.size > 0 puts result else puts "No difference on '#{path_from_name}' snapshots" end end