Socket
Book a DemoInstallSign in
Socket

standard_assert

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

standard_assert

0.3.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

standard_assert

Gem Version Build Status Code Climate Test Coverage

standard_assert is a Standard Library-like library for assertions in Ruby.
It is aimed at encouraging us to use assertion methods anywhere; Not only testing but also production.

Installation

Add this line to your application's Gemfile:

gem 'standard_assert'

And then execute:

$ bundle

Usage

Since assertion methods are defined as module functions of Assert, you can use them as instance methods to any classes that mix in the module:

require 'standard_assert'

class Stack
  include ::Assert

  def initialize
    @store = []
  end

  def pop
    assert(!@store.empty?)
    @store.pop
  end

  def push(element)
    @store.push(element)
    self
  end
end

Stack.new.pop #=> AssertionError (Expected false to be truthy.)

Or just call them with the module as a receiver:

class Stack
  def peek
    ::Assert.assert(!@store.empty?)
    @store.last
  end
end

Stack.new.peek #=> AssertionError (Expected false to be truthy.)

Note that Assert provides aseert and assert_* methods same as in Minitest::Assertions except they throw not Minitest::Assertion but AssertionError when an assertion fails.

See also: http://docs.seattlerb.org/minitest/Minitest/Assertions.html

Contributing

You should follow the steps below.

  • Fork the repository
  • Create a feature branch: git checkout -b add-new-feature
  • Commit your changes: git commit -am 'Add new feature'
  • Push the branch: git push origin add-new-feature
  • Send us a pull request

License

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

FAQs

Package last updated on 21 Dec 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.