Created
November 20, 2008 15:03
-
-
Save josephwilk/27054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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