I hope this isn't a dumb question, but can a custom matcher be written
for a possibly non-existant predicate? I know that if the object
responds to some predicate? message, RSpec will breate a custom
matcher on the fly for it. Such as be_naughty or be_nice for
sarah.naughty? and jane.nice?
But what if you want to create your own where this is not the case.
Like sarah.should_not be_on_santas_list:
Spec::Matchers.define :be_on_santas_list do |expected|
matcher do |actual|
$santas_list.include? actual
end
end
Or in the situation where the object has a predicate that returns a
string and not true or false. As is the case with
REXML::Document#stand_alone?:
match do |actual|
actual.stand_alone? == 'yes'
end
This works, but the value of expected is nil.
Is this Ok? How do others handle this? .
Thanks, and Happy Holidays.
Ed
--
Ed Howland
http://greenprogrammer.wordpress.com
http://twitter.com/ed_howland
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users