Skip to content

kachick/irb-power_assert

Repository files navigation

irb-power_assert

Build Status Gem Version

Use power_assert inspection in irb

Usage

Tested only in ruby-head and the last 2 stable versions
So require Ruby 3.2 or higher

$ gem install irb-power_assert
...installed
$ irb -r irb-power_assert
# enabled this gem

Or specify in your ~/.irbrc as below

require 'irb/power_assert'
$ irb
irb(main):004> help pa
Print PowerAssert inspection for the given expression.

Then you can use pa as an IRB command.

irb(main):001:0> pa "0".class == "3".to_i.times.map {|i| i + 1 }.class
"0".class == "3".to_i.times.map {|i| i + 1 }.class
    |     |      |    |     |                |
    |     |      |    |     |                Array
    |     |      |    |     [1, 2, 3]
    |     |      |    #<Enumerator: ...>
    |     |      3
    |     false
    String

=> false

No hack is needed in your irbrc

Thanks!

ruby/power_assert is a recent my favorites.
(the author is @k-tsj, thank you!)

It is super helpful in complex testing.

Don't say ruby/irb is old-fashioned.

I just would get irb version of yui-knk/pry-power_assert.

Latest IRB is much helpful to create own command

Honor should be bestowed upon them.

References