Power Assert for Ruby

Power Assert for Ruby. 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.

License

License

2-clause BSDL
Ruby's
Categories

Categories

Ruby Languages
GroupId

GroupId

rubygems
ArtifactId

ArtifactId

power_assert
Last Version

Last Version

0.2.3
Release Date

Release Date

Type

Type

gem
Description

Description

Power Assert for Ruby
Power Assert for Ruby. 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.
Project URL

Project URL

https://github.com/k-tsj/power_assert
Source Code Management

Source Code Management

https://github.com/k-tsj/power_assert

Download power_assert

Dependencies

test (3)

Group / Artifact Type Version
rubygems : test-unit gem [0,)
rubygems : rake gem [0,)
rubygems » simplecov gem [0,)

Project Modules

There are no modules declared in this project.

power_assert

About

Power Assert for Ruby.

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>

Related Projects

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

Requirement

  • CRuby 2.0.0 or later

Reference

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
    

Travis Build Status

Versions

Version
0.2.3