[rspec-users] array_including()

2008-08-27 Thread Matt Wynne

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.




___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] array_including()

2008-08-27 Thread Matt Wynne

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
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.




On 27 Aug 2008, at 17:16, Matt Wynne 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.






___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] array_including()

2008-08-27 Thread Zach Dennis
On Wed, Aug 27, 2008 at 12:28 PM, Matt Wynne [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 Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users