[rspec-users] Can I do foo.should (be_nil || be_empty) in rspec

Ashley Moran
2008-11-04T19:14:51Z

On Nov 04, 2008, at 5:07 pm, David Chelimsky wrote:

> FYI - if you REALLY want to match against either, it''s pretty easy
to
> do w/ simple matcher:
>
> def be_nil_or_empty
>  simple_matcher "nil? or empty? to return true" do |actual|
>    actual.nil? || actual.empty?
>  end
> end


Wow, I completely forgot about simple_matcher.  That REALLY deserves a
more prominent place in the docs!  It''s a great feature.

Would be really cool if you could do it like this though:

  simple_matcher :be_nil_or_empty, "nil? or empty? to return true" do
|
actual|
    actual.nil? || actual.empty?
  end

and have it call define_method for you.

That''s one I could hopefully do myself in time, after I''ve got
a few
Merb/DataMapper jobs out of the way.

WYDAT?  Worth filing a ticket for?

Ashley

--