mwalsh
August 27, 2008, 6:18pm
1
I found myself having to write this today:
class ArrayMatcher
def initialize(array_to_match)
@array_to_match = array_to_match
end
def ==(other)
ok = true
@array_to_match.each do |item|
ok = ok and other.include?(item)
end
ok
end
end
def array_including(array_to_match)
ArrayMatcher.new(array_to_match)
end
Is there already something in the framework that does this?
cheers,
Matt
http://blog.mattwynne.net
In case you wondered: The opinions expressed in this email are my own
and do not necessarily reflect the views of any former, current or
future employers of mine.
mwalsh
August 27, 2008, 6:33pm
2
On a similar vein, is there a neater way to express:
assigns[:events].include?(@event_1 ).should be_true
cheers,
Matt
http://blog.mattwynne.net
In case you wondered: The opinions expressed in this email are my own
and do not necessarily reflect the views of any former, current or
future employers of mine.
mwalsh
August 27, 2008, 6:45pm
3
Hello,
I believe Pat M. has implemented a matcher that does the same thing
but there has been a battle to find out what to call it:
http://www.ruby-forum.com/topic/162000#new
However I’ve not seen it in source yet.
–
Joseph W.
http://www.joesniff.co.uk
Matt W. wrote:
I found myself having to write this today:
class ArrayMatcher
def initialize(array_to_match)
@array_to_match = array_to_match
end
def ==(other)
ok = true
@array_to_match.each do |item|
ok = ok and other.include?(item)
end
ok
end
end
def array_including(array_to_match)
ArrayMatcher.new(array_to_match)
end
Is there already something in the framework that does this?
cheers,
Matt
http://blog.mattwynne.net
http://songkick.com
In case you wondered: The opinions expressed in this email are my own
and do not necessarily reflect the views of any former, current or
future employers of mine.
mwalsh
August 27, 2008, 6:53pm
4
On Wed, Aug 27, 2008 at 12:28 PM, Matt W. [email protected] wrote:
On a similar vein, is there a neater way to express:
assigns[:events].include?(@event_1 ).should be_true
assigns[:events].should include(@event_1 )
–
Zach D.
http://www.continuousthinking.com
Technology Made for Humans by humans Data Analytics Data Analytics Data has become a critical part of business for most organizations. We work with you to ensure you have confidence in your data, can properly access it, and present it in a way that...
Est. reading time: 13 minutes