-
Notifications
You must be signed in to change notification settings - Fork 86
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
Extend failure messages (issue 97) #114
base: master
Are you sure you want to change the base?
Extend failure messages (issue 97) #114
Conversation
This commit is for issue 97. So that when test fails with any of those matchers information will be shown about the matching queue (if it has jobs and expected jobs in the test is no more than 1)
@leshill could you check this PR and let me know what do you think? |
@tonatiuh Looking… |
end | ||
|
||
chain :in do |interval| | ||
@time = nil | ||
@interval = interval | ||
@time_info = "in #{@interval} seconds" | ||
@time_info = " in #{@interval} seconds" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not happy with the spacing here, leave it up to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll attend this today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issues I see if I don't add the blank space are that:
1 - There would be some inconsistency in the failure_message
method for the have_scheduled
matcher, given that only this method uses the format of ["expected that #{actual} would not have [#{expected_args.join(', ')}] scheduled", @time_info].join(' ')
, all the others follow the "expected that #{actual} would be queued with [#{expected_args.join(', ')}]#{@times_info}"
format.
2 - The last line of the failure_message
will have to be updated to ["expected that #{actual} would not have [#{expected_args.join(', ')}] scheduled", "#{@time_info},", actual_queue_message].join(' ')
so that there is a comma before showing the existent enqueued job in the failure message, and given that there may be times when the @time_info is empty then an extra blank space would appear in those cases.
What do you think?
(Please let me know if I didn't communicate well any of those points.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an example, addressing point 2:
Line 117 could be:
"but got #{actual} with [#{actual_queue_args_str}]#{@times_info} instead"
Line 248 could be:
`["expected that #{actual} would not have [#{expected_args.join(', ')}] scheduled", "#{@time_info}", actual_queue_message].join(', ')
The ", " is inserted by the caller as needed. Each part of the message is just a building block and not specifying how it is joined to the rest of the message.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think I see what you say, however, since a comma is added by each element in the array then the resulting failure text goes like the following:
expected that Person would have [a, b] scheduled, at 2015-06-08 17:41:44 -0500, but got Person with [Les, Hill] scheduled at 2015-06-08 17:41:44 -0500 instead
(Please check that there is an extra comma after "scheduled").
I don't really like having an extra comma there and I think point 1 is valid. but you tell me, I can leave it with the extra comma if that works for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, yea I did not completely rewrite it, so that will need to be addressed too.
Go ahead with my latest suggestion (extra comma) and I will fix that when I merge the PR. Thanks for the doing the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
I just realized that when there is no @time_info
two commas will appear as in:
expected that Person would have [Les, asdf] scheduled, , but got Person with [Les, Hill] scheduled instead
This goes for scenario in https://github.com/leshill/resque_spec/blob/master/spec/resque_spec/matchers_spec.rb#L357 for instance. I think you can 1) merge this as it is (since it's working and is consistent, in my opinion) or 2) I leave it is and you do the small modifications you see are needed when merging (having an extra blank space works better for me than having one extra comma).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know in case you need anything else from my side : )
This extends the failure message for the matchers be_enqueued", "have_enqueued" and "have_scheduled", so that when the test fails they will show details not only about the expected queue's job but also about existent queue's job.
Here are some examples:
be_queued:
New failure message:
Previous failure message:
have_queued:
New failure message:
Previous failure message:
have_scheduled (with
at
chain):New failure message:
Previous failure message:
have_scheduled (with
in
chain):New failure message:
Previous failure message: