[rspec-users] Problem with should_not when passing a multipleargs to a matcher

Ashley Moran ashley.moran at patchspace.co.uk
Thu Jan 7 14:23:32 EST 2010

On 7 Jan 2010, at 19:15, David Chelimsky wrote:

> Cool. I'm not sure when I'll get to this, but I'm pretty sure this would work for you for now (untested):
> Spec::Matchers.define :include_all do |*expected|
>   match do |actual|
>     expected.all? {|e| actual.include?(e)}
>   end
> end
> Spec::Matchers.define :include_any do |*expected|
>   match do |actual|
>     expected.any? {|e| actual.include?(e)}
>   end
> end

Hi Ben/David

If it's any help, I've been using three extra matchers for a while now:

  * include_all_once
  * include_all_at_least_times
  * include_any

I've put them in a gist[1], as the code to produce the error messages makes them a bit verbose.


[1] http://gist.github.com/271475


More information about the rspec-users mailing list