Sha256: 844bd3c5a088b0d11f38ec0f771497550df2d4710cca46022191f892f4e1ec22

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

require 'rubygems'
require 'hpricot'
require 'riot'
require 'riot/rr'

$:.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

9 entries across 9 versions & 2 rubygems

Version Path
ruby_slippers-0.2.15 test/support/test_helper.rb
ruby_slippers-0.2.8 test/support/test_helper.rb
ruby_slippers-0.2.4 test/support/test_helper.rb
ruby_slippers-0.2.3 test/support/test_helper.rb
ruby_slippers-0.2.0 test/support/test_helper.rb
ruby-slippers-0.1.43 test/support/test_helper.rb
ruby-slippers-0.1.40 test/support/test_helper.rb
ruby-slippers-0.1.11 test/support/test_helper.rb
ruby-slippers-0.1.7 test/support/test_helper.rb