Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minitest-assert_changes

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minitest-assert_changes

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Minitest::AssertChanges

Introduces assert_changes and assert_no_changes to Minitest.

Installation

Add this line to your application's Gemfile:

gem 'minitest-assert_changes'

And then execute:

$ bundle

Usage

assert_changes is a more general assert_difference that works with any value.

assert_changes 'Error.current', from: nil, to: 'ERR' do
  expected_bad_operation
end

Can be called with strings, to be evaluated in the binding (context) of the block given to the assertion, or a lambda.

assert_changes -> { Error.current }, from: nil, to: 'ERR' do
  expected_bad_operation
end

The from and to arguments are compared with the case operator (===).

assert_changes 'Error.current', from: nil, to: Error do
  expected_bad_operation
end

This is pretty useful, if you need to loosely compare a value. For example, you need to test a token has been generated and it has that many random characters.

user = User.start_registration
assert_changes 'user.token', to: /\w{32}/ do
  user.finish_registration
end

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 01 Aug 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc