Skip to content

Instantly share code, notes, and snippets.

@rsim

rsim/be_like.rb Secret

Created January 26, 2011 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsim/cab526d685d4103b5ce7 to your computer and use it in GitHub Desktop.
Save rsim/cab526d685d4103b5ce7 to your computer and use it in GitHub Desktop.
module Matchers
class BeLike
def initialize(expected)
@expected = expected.gsub(/\s+/, ' ').strip
end
def matches?(actual)
@actual = actual.gsub(/\s+/, ' ').strip
@expected == @actual
end
def failure_message
"expected\n#{@actual}\nto be like\n#{@expected}"
end
def negative_failure_message
"expected\n#{@actual}\nto be unlike\n#{@expected}"
end
end
def be_like(expected)
BeLike.new(expected)
end
end
it "should render to XML with attributes" do
@schema.define('FoodMart') do
description 'Demo "FoodMart" schema'
end
@schema.to_xml.should be_like <<-XML
<?xml version="1.0"?>
<Schema name="FoodMart" description="Demo &quot;FoodMart&quot; schema"/>
XML
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment