-
Notifications
You must be signed in to change notification settings - Fork 120
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 unit test for SmartAnswer::Question::Base #2340
Merged
Merged
+145
−172
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I want to introduce `shoulda` contexts into this test to make it easier to understand, but these don't appear to work in conjunction with `ActiveSupport`-style test definitions.
And improve the test names.
Other than minor comments, looks good to me |
47f773e
to
5b1987e
Compare
I'm going to do the interactive rebase against master now and force push in preparation for merging. |
And improve the test names.
And improve the test names.
Into a context and improve the test name.
I noticed this scenario was missing after I'd reorganised the tests into `shoulda` contexts.
This removes some duplication, improves the signal-to-noise ratio, and makes it clearer which is the method-under-test in each case.
The call to the constructor of `SmartAnswer::State` in the previous line sets its `current_node` to this value anyway.
There were two tests asserting against the message of this exception. While it's worthwhile testing that both scenarios raise the exception, it's not worth asserting against the message in both tests.
5b1987e
to
3103862
Compare
floehopper
added a commit
that referenced
this pull request
Mar 8, 2016
Refactor unit test for SmartAnswer::Question::Base
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This follows on from #2319 and is further work in preparation for a proper version of #2311.
I was finding it increasingly hard to read and edit the unit test for
SmartAnswer::Question::Base
, so I decided to to some preparatory refactoring.The main change in this PR is the grouping together of related tests into Shoulda contexts. I hope the commits are small enough that you can see what's going on in the diffs - you might need to ignore whitespace changes to make things clearer. I've also extracted a method to DRY up the test code a bit.
See the individual commit notes for details.
Given that I've only made changes to a single unit test and no "production" code, these changes should be pretty low risk, but it would be good if someone could give them the once over.