Skip to content

Instantly share code, notes, and snippets.

@moro
Created January 18, 2012 02:07
Show Gist options
  • Save moro/1630369 to your computer and use it in GitHub Desktop.
Save moro/1630369 to your computer and use it in GitHub Desktop.
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
@moro
Copy link
Author

moro commented Jan 18, 2012

operator matcher is not supported :-<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment