Sha256: 372cb2a1739fb733f38858abcffc93845c40679f08b0ccba52c17dad2836af7f
Contents?: true
Size: 1.08 KB
Versions: 12
Compression:
Stored size: 1.08 KB
Contents
# encoding: utf-8 RSpec::Matchers.define :reference_domains do |expected| match do |actual| domains_eq? actual, expected end failure_message_for_should do |actual| expected_domains = format_domains(expected) actual_domains = format_domains(extract_domains(actual)) "expected that \"#{actual.current_url}\" references:\n#{expected_domains}\n\nBut it references:\n#{actual_domains}\n" end failure_message_for_should_not do |actual| expected_domains = format_domains(expected) actual_domains = format_domains(extract_domains(actual)) "expected that \"#{actual.current_url}\" not references:\n#{expected_domains}\n\nBut it references:\n#{actual_domains}\n" end description do "to reference domains:\n#{format_domains(expected)}" end def domains_eq?(actual, expected) (extract_domains(actual) - expected).blank? end def extract_domains(page) page.driver.network_traffic.collect { |o| Addressable::URI.parse(o.url).host }.uniq end def format_domains(domains) domains.sort.collect { |d| format "* %s", d}.join("\n") end end
Version data entries
12 entries across 12 versions & 1 rubygems