
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
minitest-assert_errors
Advanced tools
Adds Minitest assertions to test for errors raised or not raised by Minitest itself. Most useful when testing other Minitest assertions or as a shortcut to other tests.
Currently adds the following methods:
assert_have_error()
- also aliased as assert_error_raised()
assert_no_error()
- also aliased as :refute_error()
actual.must_have_error(expected_msg)
actual.wont_have_error
Add this line to your application's Gemfile:
gem 'minitest-assert_errors'
And then execute:
bundle
Or install it yourself as:
gem install minitest-assert_errors
Add the gem to your Gemfile or .gemspec file and then load the gem in your
(test|spec)_helper.rb
file as follows:
# <snip...>
require 'minitest/autorun'
require 'minitest/assert_errors'
# <snip...>
Adding the above to your spec_helper.rb
file automatically adds the key
helper methods to the Minitest::Assertions
to test for Minitest errors
raised or not raised within your tests.
assert_have_error(expected_msg, klass = Minitest::Assertion, &blk)
-- also aliased as: assert_error_raised()
Assertion method to test for an error raised by Minitest
assert_have_error('error message') { assert(false, 'error message') }
# or
proc {
assert(false, 'error message')
}.must_have_error('error message')
Produces a longer error message, combining the given error message with the default error message, when something is wrong.
NOTE! The expected error message can be a String
or Regexp
.
assert_have_error(/error message.+Actual:\s+\"b\"/m) do
assert_equal('a','b', 'error message')
end
# or
proc {
assert_equal('a','b', 'error message')
}.must_have_error(/error message.+Actual:\s+\"b\"/m)
assert_no_error(&blk)
-- also aliased as: refute_error()
or refute_error_raised()
or
assert_no_error_raised()
Assertion method to test for no error being raised by Minitest test.
assert_no_error() { assert(true, 'error message') }
# or
proc { assert(true) }.wont_have_error
Produces a longer error message, combining the given error message with the default error message, when something is wrong.
NOTE! The expected error message can be a String
or Regexp
.
assert_no_error { assert_equal('a', :a, 'error message') }
#=> "error message.\nExpected: \"a\"\n Actual: :a"
proc {
assert_equal('a', :a, 'error message')
}.wont_have_error
#=> "error message.\nExpected: \"a\"\n Actual: :a"
This Gem depends upon the following:
bundler (~> 1.10)
rake (~> 10.0)
minitest-rg
simplecov [optional]
rubocop [optional]
Bug reports and pull requests are welcome on GitHub.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
After checking out the repo, run bundle install
to install dependencies.
Then, run bundle exec rake spec
to run the tests.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, update the version number in version.rb
, and
then run bundle exec rake release
, which will create a git tag for the
version, push git commits and tags, and push the .gem
file to
rubygems.org.
Copyright (c) 2015 Kematzy
Released under the MIT License. See LICENSE for further details.
FAQs
Unknown package
We found that minitest-assert_errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.