-
Notifications
You must be signed in to change notification settings - Fork 246
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
Refactor testing of flash messages #7386
Refactor testing of flash messages #7386
Conversation
Add test cases to assign_all, unassign_all, and unassign_single methods
Implement custom matcher for have_message and contain_message Refactor marks_graders_controller_spec notes_controller_spec peer_reviews_controller_spec
… test-message-refactor
Pull Request Test Coverage Report for Build 12997204113Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
@Raine-Yang-UofT nice work! I left some inline comments; please also make sure to update the changelog as well.
spec/support/custom_matchers.rb
Outdated
end | ||
end | ||
|
||
def strip_html(text) |
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.
It isn't necessary to define this custom function. Instead, reuse the existing extract_text
helper, which was previously used to process some of the flash messages.
spec/support/custom_matchers.rb
Outdated
end | ||
|
||
failure_message do |actual| | ||
actual_stripped = Array(actual).map { |m| strip_html(m.to_s) } |
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.
We should wrap this block (and the similar one in :contain_message
in a :nocov:
so that it isn't included in the coverage report.
Introduce custom matchers have_message and contain_message for checking flash messages.
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
Implement custom Rspec matchers
contain_message
andhave_message
that verifies the content of flash messages.Refactor all existing unit tests to use the new matcher.
...
Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)
Type of Change
(Write an
X
or a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]
into a[x]
in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)