Sha256: 726f1c1420dedb0335850d1a9c4ea07649c135ddc7967c6d1f77f04a162425b5
Contents?: true
Size: 1.15 KB
Versions: 7
Compression:
Stored size: 1.15 KB
Contents
require 'rubygems' require 'hpricot' require 'riot' $:.unshift File.dirname(__FILE__) $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require File.expand_path('../../../lib/ruby_slippers', __FILE__) URL = "http://domain.oz" AUTHOR = "author" class IncludesHTMLMacro < Riot::AssertionMacro register :includes_html def evaluate(actual, expected) doc = Hpricot.parse(actual) expected = expected.to_a.flatten if (doc/expected.first).empty? fail("expected #{actual} to contain a <#{expected.first}>") elsif !(doc/expected.first).inner_html.match(expected.last) fail("expected <#{expected.first}> to contain #{expected.last}") else pass end end end class IncludesElementsMacro < Riot::AssertionMacro register :includes_elements def evaluate(actual, selector, count) doc = Hpricot.parse(actual) (doc/selector).size == count ? pass : fail("expected #{actual} to contain #{count} #{selector}(s)") end end class WithinMacro < Riot::AssertionMacro register :within def evaluate(actual, expected) expected.include?(actual) ? pass : fail("expected #{actual} to be within #{expected}") end end
Version data entries
7 entries across 7 versions & 1 rubygems