minitest-bonus-assertions¶ ↑
- code
- bugs
- continuous integration
Description¶ ↑
Bonus assertions for Minitest, providing assertions I use frequently, supporting only Ruby 2.0 or better.
Features¶ ↑
New assertions:
-
assert_false
: requires that the value be exactlyfalse
. (must_be_false
) -
assert_true
: requires that the value be exactlytrue
. (must_be_true
) -
assert_between
: requires that the value be strictly between the low and high values provided, or the range (this test is boundary-exclusive). (must_be_between
) -
assert_has_keys
/refute_missing_keys
: requires that the object contains all of the keys expected. (must_have_keys
) -
assert_missing_keys
/refute_has_keys
: requires that the object not have any of the keys expected. (must_not_have_keys
) -
assert_raises_with_message
: requires that the exception raised in the provided block has a specific message (tested withassert_equal
). (must_raise_with_message
) -
assert_set_equal
: requires that the actual enumerable have the same values as the expected enumerable, without regard to order and ignoring duplicate values. (must_equal_set
) -
refute_set_equal
: requires that the actual enumerable not have the same values as the expected enumerable. (must_not_equal_set
) -
assert_result_equal
: requires that the actual is equal to the result of evaluating an expression.
I am also providing the Minitest-tester code I use as something that can be required by other developers. This should only be used to test Minitest
assertions and extensions. For more information on Minitest::AssertionTests
, see its documentation.
Background¶ ↑
minitest-bonus-assertions started life as a patch to Ben Somer’s minitest-extra-assertions. There were some nice assertions included, but there were other changes that needed to be made to bring it up to support Minitest
5. There was also an override to the default assert_match
implementation meant to ease the transition from Test::Unit (the main reason he wrote this assertion plugin for Minitest
in the first place). I do not believe this is sensible five major versions into Minitest: I removed it. Ben did not feel comfortable making this particular change, so I felt that the best way to provide the original assertions and my new assertions—without the assert_match
override—was to fork this as a new project. I am indebted to Ben and his contributors for writing these assertions in the first place.
Install¶ ↑
Add it to your Gemfile:
gem 'minitest-bonus-assertions', '~> 1.1'
Or manually install:
% gem install minitest-bonus-assertions
minitest-bonus-assertions Semantic Versioning¶ ↑
minitest-bonus-assertions uses a Semantic Versioning scheme with one change:
-
When PATCH is zero (
0
), it will be omitted from version references.
Contributor Code of Conduct¶ ↑
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
-
The use of sexualized language or imagery
-
Personal attacks
-
Trolling or insulting/derogatory comments
-
Public or private harassment
-
Publishing other's private information, such as physical or electronic addresses, without explicit permission
-
Other unethical or unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the Contributor Covenant, version 1.2.0, available at contributor-covenant.org/version/1/2/0/.
Contributing¶ ↑
I value any contribution to minitest-bonus-assertions you can provide: a bug report, a feature request, or code contributions.
As minitest-bonus-assertions is a mature codebase, there are a few guidelines:
-
Changes will not be accepted without tests. The test suite is written with Minitest (of course).
-
Match my coding style.
-
Use a thoughtfully-named topic branch that contains your change. Rebase your commits into logical chunks as necessary.
-
Do not change the version number; when your patch is accepted and a release is made, the version will be updated at that point.
-
Submit a GitHub pull request with your changes.
-
New behaviours require new or updated documentation.
Test Dependencies¶ ↑
minitest-bonus-assertions uses Ryan Davis’s Hoe to manage the release process, and it adds a number of rake tasks. You will mostly be interested in:
$ rake
which runs the tests the same way that:
$ rake test $ rake travis
will do.
To assist with the installation of the development dependencies for minitest-bonus-assertions, I have provided the simplest possible Gemfile pointing to the (generated) minitest-bonus-assertions.gemspec
file. This will permit you to do:
$ bundle install
to get the development dependencies. If you aleady have hoe
installed, you can accomplish the same thing with:
$ rake newb
This task will install any missing dependencies, run the tests/specs, and generate the RDoc.
Workflow¶ ↑
Here's the most direct way to get your work merged into the project:
-
Fork the project.
-
Clone down your fork (
git clone git://github.com/halostatue/minitest-bonus-assertions.git
). -
Create a topic branch to contain your change (
git checkout -b my_awesome_feature
). -
Hack away, add tests. Not necessarily in that order.
-
Make sure everything still passes by running
rake
. -
If necessary, rebase your commits into logical chunks, without errors.
-
Push the branch up (
git push origin my_awesome_feature
). -
Create a pull request against halostatue/minitest-bonus-assertions and describe what your change does and the why you think it should be merged.
Contributors¶ ↑
-
Austin Ziegler forked minitest-bonus-assertions.
-
Ben Somers (@bensomers) created minitest-extra-assertions
-
Justin George (@jaggederest) added assert_between.
Licence¶ ↑
This software is available under an MIT-style licence.
-
Copyright 2015–2017 Austin Ziegler
-
Copyright 2012 Ben Somers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.