Created
January 18, 2012 02:07
-
-
Save moro/1630369 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module EachActual | |
class Proxy | |
def initialize(collection, attr = nil) | |
@actual = attr ? collection.map(&:attr) : collection | |
end | |
def should(matcher = nil) | |
@actual.each do |obj| | |
obj.should matcher | |
end | |
end | |
def should_not(matcher = nil) | |
@actual.each do |obj| | |
obj.should_not matcher | |
end | |
end | |
end | |
def each_of(collection) | |
Proxy.new(collection) | |
end | |
end | |
describe Array do | |
include EachActual | |
let(:array) { [*(0..9)] } | |
specify { each_of(array).should be_instance_of(Fixnum) } | |
specify { each_of(array).should_not be_nil } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
operator matcher is not supported :-<