Skip to content

Instantly share code, notes, and snippets.

@josephwilk
Created November 20, 2008 15:03
Show Gist options
  • Save josephwilk/27054 to your computer and use it in GitHub Desktop.
Save josephwilk/27054 to your computer and use it in GitHub Desktop.
require 'set'
module BagOfMatchers
class Bag
def initialize(list)
@list = Set.new(list)
end
def matches?(list)
@compare_list = Set.new(list)
@list == @compare_list
end
def failure_message
"expected #{@list.inspect} to be a bag of #{@compare_list.inspect}, but it is not"
end
def negative_failure_message
"expected #{@list.inspect} not to be a bag of #{@compare_list.inspect}, but it is"
end
end
def be_bag_of(list)
Bag.new(list)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment