New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

power_assert

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

power_assert

  • 2.0.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

power_assert

About

Power Assert shows each value of variables and method calls in the expression. It is useful for testing, providing which value wasn't correct when the condition is not satisfied.

Failure:
   assert { 3.times.to_a.include?(3) }
              |     |    |
              |     |    false
              |     [0, 1, 2]
              #<Enumerator: 3:times>

In general, you don't need to use this library directly. Use following test frameworks or extensions instead.

  • test-unit(>= 3.0.0)
  • minitest-power_assert
  • rspec-power_assert
  • rspec-matchers-power_assert_matchers
  • pry-power_assert
  • pry-byebug-power_assert
  • irb-power_assert
  • power_p

Requirement

  • CRuby 2.5+

Configuration

To colorize output messages, add require "power_assert/colorize" to your code. (It requires CRuby 3.0.1+ or irb 1.3.1+)

Known Limitations

  • Expressions must be put in one line. Expressions with folded long lines produce nothing report, e.g.:
assert do
  # reported
  func(foo: 0123456789, bar: "abcdefg")
end

assert do
  # won't be reported
  func(foo: 0123456789,
       bar: "abcdefg")
end
  • Expressions must have one or more method call. Expressions with no method call produce nothing report, e.g.:
val = false
assert do
  # reported
  val == true
end

assert do
  # won't be reported
  val
end
  • Returned values from accessor methods, method missing, or "super" produce nothing report, e.g:
class Foo
  attr_accessor :val
end
foo = Foo.new
foo.val = false

assert do
  # reported (only the value of "foo" and the literal "true")
  foo.val == true
end

assert do
  # won't be reported
  foo.val
end
  • Expressions should not have conditional branches. Expressions with such conditional codes may produce nothing report, e.g.:
condition = true
expected = false
actual = true
assert do
  # this will fail but nothing reported
  condition ? expected == actual : expected == actual
end

Reference

FAQs

Package last updated on 23 Dec 2024

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