-
-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output chained matchers description #1439
Comments
This is not how you chain matchers. |
Thanks, but I dont want to chain matcher with the same subject. |
I understand what you are trying to work around. This will be solved in this pr #1319, but it’s a breaking change, so only in RSpec 4. |
Sounds nice but it seems to me that the PR you've linked will only change the output diff on test failures. Am I wrong ? In the matcher above, I have no problem to output a good failure message of chained matchers ... except for the description part. matcher :have_html_body do
chain :to, :other_matcher
chain :not_to, :other_negative_matcher
failure_message do
message = "expected to #{description}"
message += "\n#{other_matcher&.failure_message}" if other_matcher
message += "\n#{other_negative_matcher&.failure_message_when_negated}" if other_negative_matcher
message
end
end |
Do you have any issue with printed example descriptions of chained matchers built using the built-in compound mechanism? |
Confusingly, i can’t tell if dsl-defined matchers are compoundable by default. |
Subject of the issue
I've created a custom matcher which allows to chain other matchers against a computed value :
I can then chain any matchers to match the parsed body :
It works fine, but descriptions are cumbersome :
Expected behavior
It should generate a readable description :
Your environment
config.include_chain_clauses_in_custom_matcher_descriptions
is already set totrue
Investigation
There are 3 methods involved to generate chained description :
RSpec::Matchers::DSL#chained_method_clause_sentences
RSpec::Matchers::EnglishPhrasing#list
RSpec::Support::ObjectFormatter.format
I'm not sure which one is the most relevant to fix the issue but my guess is EnglishPhrasing.
Something like :
The text was updated successfully, but these errors were encountered: