Skip to content

Instantly share code, notes, and snippets.

@hawx
Created March 30, 2011 15:55
Show Gist options
  • Save hawx/894659 to your computer and use it in GitHub Desktop.
Save hawx/894659 to your computer and use it in GitHub Desktop.
All_of matcher for rspec
# Not the best example, but
#
# it "is an array of Hashes" do
# all_of(subject).should be_kind_of Hash
# end
#
class AllOf
def initialize(items)
@items = items
end
def should(*args)
@items.all? {|i| i.should(*args)}
end
def should_not(*args)
@items.all? {|i| i.should_not(*args)}
end
end
def all_of(items)
AllOf.new(items)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment