By defining a custom be_acceptable
matcher, you are telling RSpec you want the description and failure message to use “be acceptable” in the description and failure message.
OTOH, if you simply want to use be_acceptable
, and don’t care about it actually being a custom matcher, you can define it simply as a well-named helper method that returns the compound matcher expression:
module MatcherHelpers
def be_acceptable
be_even.and be > 10
end
end
RSpec.configure do |c|
c.include MatcherHelpers
end
…which will give you the exact same failure as your first example.
By defining a custom
be_acceptable
matcher, you are telling RSpec you want the description and failure message to use “be acceptable” in the description and failure message.OTOH, if you simply want to use
be_acceptable
, and don’t care about it actually being a custom matcher, you can define it simply as a well-named helper method that returns the compound matcher expression:module MatcherHelpers def be_acceptable be_even.and be > 10 end end RSpec.configure do |c| c.include MatcherHelpers end
…which will give you the exact same failure as your first example.