power_assert 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +32 -0
- data/README.md +96 -0
- data/lib/power_assert.rb +3 -10
- data/lib/power_assert/colorize.rb +2 -4
- data/lib/power_assert/configuration.rb +17 -17
- data/lib/power_assert/context.rb +27 -32
- data/lib/power_assert/enable_tracepoint_events.rb +33 -66
- data/lib/power_assert/inspector.rb +9 -8
- data/lib/power_assert/version.rb +1 -1
- data/power_assert.gemspec +5 -5
- metadata +15 -15
- data/.travis.yml +0 -22
- data/README.rdoc +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d3d0e5985a6bb521449ef71f42225297f74cd879017bc0fa9fc43e1c7a612f4
|
4
|
+
data.tar.gz: 63dbbb1eb926c54fcefc1fb3933f2a5bd7970d3e98a9074d103d378492581d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72392cf0e4ab54507b191a3552664531933c554f3aa94883d75cea07b3c37d49c969ec6c06c0ff37b8704e7d7de5b5e500dc251d8de8f17561253e635dfc2f45
|
7
|
+
data.tar.gz: f6b2be0b7dfa3e06a6f28bdec0dae7b63150cffc9f47a5499f07ffd94f1cf7b332d5d2b2796946cbddded9931676263a8064874697dbc9ee026e6a05b46eb7f4
|
@@ -0,0 +1,32 @@
|
|
1
|
+
on: [ push, pull_request ]
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
name: >-
|
6
|
+
Test (${{ matrix.ruby-version }} / ${{ matrix.os }} / TEST_SYMLINK: ${{ matrix.TEST_SYMLINK }})
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby-version: [ '3.0', 2.7, 2.6, 2.5, head ]
|
11
|
+
os: [ ubuntu-latest, macos-latest ]
|
12
|
+
TEST_SYMLINK: [ yes, no ]
|
13
|
+
runs-on: ${{ matrix.os }}
|
14
|
+
env:
|
15
|
+
TEST_SYMLINK: ${{ matrix.TEST_SYMLINK }}
|
16
|
+
continue-on-error: ${{ matrix.ruby-version == 'head' }}
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Run before_script
|
25
|
+
run: |
|
26
|
+
bundle exec rake before_script
|
27
|
+
- name: Run the test suite
|
28
|
+
run: |
|
29
|
+
bundle exec rake
|
30
|
+
- name: Run after_script
|
31
|
+
run: |
|
32
|
+
bundle exec rake after_script
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# power_assert
|
2
|
+
## About
|
3
|
+
Power Assert shows each value of variables and method calls in the expression.
|
4
|
+
It is useful for testing, providing which value wasn't correct when the condition is not satisfied.
|
5
|
+
|
6
|
+
Failure:
|
7
|
+
assert { 3.times.to_a.include?(3) }
|
8
|
+
| | |
|
9
|
+
| | false
|
10
|
+
| [0, 1, 2]
|
11
|
+
#<Enumerator: 3:times>
|
12
|
+
|
13
|
+
## Related Projects
|
14
|
+
In general, you don't need to use this library directly.
|
15
|
+
Use following test frameworks or extensions instead.
|
16
|
+
|
17
|
+
* [test-unit](https://github.com/test-unit/test-unit)(>= 3.0.0)
|
18
|
+
* [Document](http://test-unit.github.io/test-unit/en/Test/Unit/Assertions.html#assert-instance_method)
|
19
|
+
* [minitest-power_assert](https://github.com/hsbt/minitest-power_assert)
|
20
|
+
* [rspec-power_assert](https://github.com/joker1007/rspec-power_assert)
|
21
|
+
* [pry-power_assert](https://github.com/yui-knk/pry-power_assert)
|
22
|
+
* [pry-byebug-power_assert](https://github.com/k-tsj/pry-byebug-power_assert)
|
23
|
+
* [power_p](https://github.com/k-tsj/power_p)
|
24
|
+
|
25
|
+
## Requirement
|
26
|
+
* CRuby 2.5+
|
27
|
+
|
28
|
+
## Configuration
|
29
|
+
To colorize output messages, add <code>require "power_assert/colorize"</code> to your code.
|
30
|
+
(It requires CRuby 3.0.1+ or irb 1.3.1+)
|
31
|
+
|
32
|
+
## Known Limitations
|
33
|
+
* Expressions must be put in one line. Expressions with folded long lines produce nothing report, e.g.:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
assert do
|
37
|
+
# reported
|
38
|
+
func(foo: 0123456789, bar: "abcdefg")
|
39
|
+
end
|
40
|
+
|
41
|
+
assert do
|
42
|
+
# won't be reported
|
43
|
+
func(foo: 0123456789,
|
44
|
+
bar: "abcdefg")
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
* Expressions must have one or more method call. Expressions with no method call produce nothing report, e.g.:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
val = false
|
52
|
+
assert do
|
53
|
+
# reported
|
54
|
+
val == true
|
55
|
+
end
|
56
|
+
|
57
|
+
assert do
|
58
|
+
# won't be reported
|
59
|
+
val
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
* Returned values from accessor methods, method missing, or "super" produce nothing report, e.g:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
class Foo
|
67
|
+
attr_accessor :val
|
68
|
+
end
|
69
|
+
foo = Foo.new
|
70
|
+
foo.val = false
|
71
|
+
|
72
|
+
assert do
|
73
|
+
# reported (only the value of "foo" and the literal "true")
|
74
|
+
foo.val == true
|
75
|
+
end
|
76
|
+
|
77
|
+
assert do
|
78
|
+
# won't be reported
|
79
|
+
foo.val
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
* Expressions should not have conditional branches. Expressions with such conditional codes may produce nothing report, e.g.:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
condition = true
|
87
|
+
expected = false
|
88
|
+
actual = true
|
89
|
+
assert do
|
90
|
+
# this will fail but nothing reported
|
91
|
+
condition ? expected == actual : expected == actual
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
## Reference
|
96
|
+
* [Power Assert in Ruby (at RubyKaigi 2014) // Speaker Deck](https://speakerdeck.com/k_tsj/power-assert-in-ruby)
|
data/lib/power_assert.rb
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
captured = false
|
8
8
|
TracePoint.new(:return, :c_return) do |tp|
|
9
9
|
captured = true
|
10
|
-
unless tp.binding and tp.return_value
|
10
|
+
unless tp.binding and tp.return_value and tp.callee_id
|
11
11
|
raise ''
|
12
12
|
end
|
13
13
|
end.enable { __id__ }
|
@@ -17,22 +17,15 @@ rescue
|
|
17
17
|
raise LoadError, 'Fully compatible TracePoint API required'
|
18
18
|
end
|
19
19
|
|
20
|
-
require 'power_assert/version'
|
21
|
-
require 'power_assert/configuration'
|
22
20
|
require 'power_assert/context'
|
21
|
+
require 'power_assert/configuration'
|
22
|
+
require 'power_assert/version'
|
23
23
|
|
24
24
|
module PowerAssert
|
25
25
|
POWER_ASSERT_LIB_DIR = File.dirname(caller_locations(1, 1).first.path)
|
26
26
|
INTERNAL_LIB_DIRS = {PowerAssert => POWER_ASSERT_LIB_DIR}
|
27
27
|
private_constant :POWER_ASSERT_LIB_DIR, :INTERNAL_LIB_DIRS
|
28
28
|
|
29
|
-
# For backward compatibility
|
30
|
-
IGNORED_LIB_DIRS = INTERNAL_LIB_DIRS
|
31
|
-
private_constant :IGNORED_LIB_DIRS
|
32
|
-
if respond_to?(:deprecate_constant)
|
33
|
-
deprecate_constant :IGNORED_LIB_DIRS
|
34
|
-
end
|
35
|
-
|
36
29
|
class << self
|
37
30
|
def start(assertion_proc_or_source, assertion_method: nil, source_binding: TOPLEVEL_BINDING)
|
38
31
|
if respond_to?(:clear_global_method_cache, true)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module PowerAssert
|
2
2
|
class << self
|
3
3
|
def configuration
|
4
|
-
@configuration ||= Configuration[false,
|
4
|
+
@configuration ||= Configuration[false, true, false, :p]
|
5
5
|
end
|
6
6
|
|
7
7
|
def configure
|
@@ -9,35 +9,35 @@ module PowerAssert
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
class Configuration < Struct.new(:lazy_inspection, :_trace_alias_method, :_redefinition, :_colorize_message, :_use_pp)
|
16
|
-
def _trace_alias_method=(bool)
|
17
|
-
super
|
18
|
-
if SUPPORT_ALIAS_METHOD
|
19
|
-
warn 'power_assert: _trace_alias_method option is obsolete. You no longer have to set it.'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def _colorize_message=(bool)
|
12
|
+
class Configuration < Struct.new(:lazy_inspection, :_redefinition, :colorize_message, :inspector)
|
13
|
+
def colorize_message=(bool)
|
24
14
|
if bool
|
25
|
-
require '
|
15
|
+
require 'irb/color'
|
16
|
+
if inspector == :pp
|
17
|
+
require 'irb/color_printer'
|
18
|
+
end
|
26
19
|
end
|
27
20
|
super
|
28
21
|
end
|
29
22
|
|
30
23
|
def lazy_inspection=(bool)
|
31
24
|
unless bool
|
32
|
-
raise 'lazy_inspection option must be enabled when using pp' if
|
25
|
+
raise 'lazy_inspection option must be enabled when using pp' if inspector == :pp
|
33
26
|
end
|
34
27
|
super
|
35
28
|
end
|
36
29
|
|
37
|
-
def
|
38
|
-
|
30
|
+
def inspector=(inspector)
|
31
|
+
case inspector
|
32
|
+
when :pp
|
39
33
|
raise 'lazy_inspection option must be enabled when using pp' unless lazy_inspection
|
40
34
|
require 'pp'
|
35
|
+
if colorize_message
|
36
|
+
require 'irb/color_printer'
|
37
|
+
end
|
38
|
+
when :p
|
39
|
+
else
|
40
|
+
raise ArgumentError, "unknown inspector: #{inspector}"
|
41
41
|
end
|
42
42
|
super
|
43
43
|
end
|
data/lib/power_assert/context.rb
CHANGED
@@ -12,36 +12,31 @@ module PowerAssert
|
|
12
12
|
@target_thread = Thread.current
|
13
13
|
method_id_set = nil
|
14
14
|
@return_values = []
|
15
|
-
trace_alias_method = PowerAssert.configuration._trace_alias_method
|
16
15
|
@trace_return = TracePoint.new(:return, :c_return) do |tp|
|
17
|
-
|
18
|
-
unless
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
tp.return_value :
|
35
|
-
InspectedValue.new(SafeInspectable.new(tp.return_value).inspect)
|
36
|
-
@return_values << Value[method_id.to_s, val, locs[idx].lineno, nil]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
rescue Exception => e
|
40
|
-
warn "power_assert: [BUG] Failed to trace: #{e.class}: #{e.message}"
|
41
|
-
if e.respond_to?(:full_message)
|
42
|
-
warn e.full_message.gsub(/^/, 'power_assert: ')
|
16
|
+
unless method_id_set
|
17
|
+
next unless Thread.current == @target_thread
|
18
|
+
method_id_set = @parser.method_id_set
|
19
|
+
end
|
20
|
+
method_id = tp.callee_id
|
21
|
+
next if ! method_id_set[method_id]
|
22
|
+
next if tp.event == :c_return and
|
23
|
+
not (@parser.lineno == tp.lineno and @parser.path == tp.path)
|
24
|
+
locs = PowerAssert.app_caller_locations
|
25
|
+
diff = locs.length - base_caller_length
|
26
|
+
if (tp.event == :c_return && diff == 1 || tp.event == :return && diff <= 2) and Thread.current == @target_thread
|
27
|
+
idx = -(base_caller_length + 1)
|
28
|
+
if @parser.path == locs[idx].path and @parser.lineno == locs[idx].lineno
|
29
|
+
val = PowerAssert.configuration.lazy_inspection ?
|
30
|
+
tp.return_value :
|
31
|
+
InspectedValue.new(SafeInspectable.new(tp.return_value).inspect)
|
32
|
+
@return_values << Value[method_id.to_s, val, locs[idx].lineno, nil]
|
43
33
|
end
|
44
34
|
end
|
35
|
+
rescue Exception => e
|
36
|
+
warn "power_assert: [BUG] Failed to trace: #{e.class}: #{e.message}"
|
37
|
+
if e.respond_to?(:full_message)
|
38
|
+
warn e.full_message.gsub(/^/, 'power_assert: ')
|
39
|
+
end
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
@@ -61,8 +56,8 @@ module PowerAssert
|
|
61
56
|
end
|
62
57
|
|
63
58
|
def build_assertion_message(parser, return_values)
|
64
|
-
if PowerAssert.configuration.
|
65
|
-
line =
|
59
|
+
if PowerAssert.configuration.colorize_message
|
60
|
+
line = IRB::Color.colorize_code(parser.line, ignore_error: true)
|
66
61
|
else
|
67
62
|
line = parser.line
|
68
63
|
end
|
@@ -93,12 +88,12 @@ module PowerAssert
|
|
93
88
|
end.join
|
94
89
|
lines = []
|
95
90
|
lines << line.chomp
|
96
|
-
lines << sprintf(fmt, vals.each_with_object({}) {|v, h| h[v.display_offset
|
91
|
+
lines << sprintf(fmt, vals.each_with_object({}) {|v, h| h[:"#{v.display_offset}"] = '|' }).chomp
|
97
92
|
vals.each do |i|
|
98
|
-
inspected_val = SafeInspectable.new(
|
93
|
+
inspected_val = SafeInspectable.new(Inspector.new(i.value, i.display_offset)).inspect
|
99
94
|
inspected_val.each_line do |l|
|
100
95
|
map_to = vals.each_with_object({}) do |j, h|
|
101
|
-
h[j.display_offset
|
96
|
+
h[:"#{j.display_offset}"] = [l, '|', ' '][i.display_offset <=> j.display_offset]
|
102
97
|
end
|
103
98
|
lines << encoding_safe_rstrip(sprintf(fmt, map_to))
|
104
99
|
end
|
@@ -2,85 +2,52 @@ require 'power_assert/configuration'
|
|
2
2
|
|
3
3
|
if defined?(RubyVM)
|
4
4
|
if PowerAssert.configuration._redefinition
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
]
|
18
|
-
|
19
|
-
basic_operators = [
|
20
|
-
:+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=,
|
21
|
-
:length, :size, :empty?, :succ, :>, :>=, :!, :!=, :=~, :freeze, :-@, :max, :min, :nil?
|
22
|
-
]
|
23
|
-
|
24
|
-
bug11182 = Class.new do
|
25
|
-
def fixed?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
refine bug11182 do
|
31
|
-
def fixed?
|
5
|
+
module PowerAssert
|
6
|
+
# set redefined flag
|
7
|
+
basic_classes = [
|
8
|
+
Integer, Float, String, Array, Hash, Symbol, Time, Regexp, NilClass, TrueClass, FalseClass
|
9
|
+
]
|
10
|
+
|
11
|
+
verbose = $VERBOSE
|
12
|
+
begin
|
13
|
+
$VERBOSE = nil
|
14
|
+
[:Fixnum, :Bignum].each do |c|
|
15
|
+
if Object.const_defined?(c) and (c = Object.const_get(c)) != Integer
|
16
|
+
basic_classes << c
|
32
17
|
end
|
33
18
|
end
|
19
|
+
ensure
|
20
|
+
$VERBOSE = verbose
|
21
|
+
end
|
34
22
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if (bug11182.new.fixed? rescue false)
|
41
|
-
basic_classes.each do |klass|
|
42
|
-
basic_operators.each do |bop|
|
43
|
-
if klass.public_method_defined?(bop)
|
44
|
-
refine(klass) do
|
45
|
-
define_method(bop) {}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
else
|
51
|
-
# workaround for https://bugs.ruby-lang.org/issues/11182
|
52
|
-
basic_classes.each do |klass|
|
53
|
-
basic_operators.each do |bop|
|
54
|
-
if klass.public_method_defined?(bop)
|
55
|
-
klass.ancestors.find {|i| i.instance_methods(false).index(bop) }.module_eval do
|
56
|
-
public bop
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
23
|
+
basic_operators = [
|
24
|
+
:+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=,
|
25
|
+
:length, :size, :empty?, :succ, :>, :>=, :!, :!=, :=~, :freeze, :-@, :max, :min, :nil?
|
26
|
+
]
|
61
27
|
|
62
|
-
|
63
|
-
|
28
|
+
basic_classes.each do |klass|
|
29
|
+
basic_operators.each do |bop|
|
30
|
+
if klass.public_method_defined?(bop)
|
31
|
+
refine(klass) do
|
32
|
+
define_method(bop) {}
|
64
33
|
end
|
65
34
|
end
|
66
35
|
end
|
36
|
+
end
|
67
37
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
38
|
+
# bypass check_cfunc
|
39
|
+
refine BasicObject do
|
40
|
+
def !
|
41
|
+
end
|
72
42
|
|
73
|
-
|
74
|
-
end
|
43
|
+
def ==
|
75
44
|
end
|
45
|
+
end
|
76
46
|
|
77
|
-
|
78
|
-
|
79
|
-
end
|
47
|
+
refine Module do
|
48
|
+
def ==
|
80
49
|
end
|
81
50
|
end
|
82
|
-
ensure
|
83
|
-
$VERBOSE = verbose
|
84
51
|
end
|
85
52
|
end
|
86
53
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'power_assert/configuration'
|
2
|
+
require 'io/console/size'
|
2
3
|
|
3
4
|
module PowerAssert
|
4
5
|
class InspectedValue
|
@@ -34,22 +35,22 @@ module PowerAssert
|
|
34
35
|
end
|
35
36
|
private_constant :SafeInspectable
|
36
37
|
|
37
|
-
class
|
38
|
+
class Inspector
|
38
39
|
def initialize(value, indent)
|
39
40
|
@value = value
|
40
41
|
@indent = indent
|
41
42
|
end
|
42
43
|
|
43
44
|
def inspect
|
44
|
-
if PowerAssert.configuration.
|
45
|
-
if PowerAssert.configuration.
|
46
|
-
width = [
|
47
|
-
|
45
|
+
if PowerAssert.configuration.colorize_message
|
46
|
+
if PowerAssert.configuration.inspector == :pp
|
47
|
+
width = [IO.console_size[1] - 1 - @indent, 10].max
|
48
|
+
IRB::ColorPrinter.pp(@value, '', width)
|
48
49
|
else
|
49
|
-
|
50
|
+
IRB::Color.colorize_code(@value.to_s, ignore_error: true)
|
50
51
|
end
|
51
52
|
else
|
52
|
-
if PowerAssert.configuration.
|
53
|
+
if PowerAssert.configuration.inspector == :pp
|
53
54
|
PP.pp(@value, '')
|
54
55
|
else
|
55
56
|
@value.inspect
|
@@ -57,5 +58,5 @@ module PowerAssert
|
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
60
|
-
private_constant :
|
61
|
+
private_constant :Inspector
|
61
62
|
end
|
data/lib/power_assert/version.rb
CHANGED
data/power_assert.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ['kazuki@callcc.net']
|
11
11
|
s.homepage = 'https://github.com/ruby/power_assert'
|
12
12
|
s.summary = "Power Assert for Ruby"
|
13
|
-
s.description = "Power Assert
|
13
|
+
s.description = "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."
|
14
14
|
|
15
15
|
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
16
|
f.match(%r{^(test|spec|features|benchmark)/})
|
@@ -22,10 +22,10 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency 'rake'
|
23
23
|
s.add_development_dependency 'simplecov'
|
24
24
|
s.add_development_dependency 'bundler'
|
25
|
-
s.add_development_dependency '
|
25
|
+
s.add_development_dependency 'irb', '>= 1.3.1'
|
26
26
|
s.add_development_dependency 'byebug'
|
27
27
|
s.add_development_dependency 'benchmark-ips'
|
28
|
-
s.extra_rdoc_files = ['README.
|
29
|
-
s.rdoc_options = ['--main', 'README.
|
30
|
-
s.licenses = ['2-
|
28
|
+
s.extra_rdoc_files = ['README.md']
|
29
|
+
s.rdoc_options = ['--main', 'README.md']
|
30
|
+
s.licenses = ['BSD-2-Clause', "Ruby"]
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: power_assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuki Tsujimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: irb
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.3.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.3.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,23 +108,23 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description: Power Assert
|
112
|
-
|
113
|
-
|
111
|
+
description: Power Assert shows each value of variables and method calls in the expression.
|
112
|
+
It is useful for testing, providing which value wasn't correct when the condition
|
113
|
+
is not satisfied.
|
114
114
|
email:
|
115
115
|
- kazuki@callcc.net
|
116
116
|
executables: []
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files:
|
119
|
-
- README.
|
119
|
+
- README.md
|
120
120
|
files:
|
121
|
+
- ".github/workflows/ci.yml"
|
121
122
|
- ".gitignore"
|
122
|
-
- ".travis.yml"
|
123
123
|
- BSDL
|
124
124
|
- COPYING
|
125
125
|
- Gemfile
|
126
126
|
- LEGAL
|
127
|
-
- README.
|
127
|
+
- README.md
|
128
128
|
- Rakefile
|
129
129
|
- bin/console
|
130
130
|
- bin/setup
|
@@ -139,13 +139,13 @@ files:
|
|
139
139
|
- power_assert.gemspec
|
140
140
|
homepage: https://github.com/ruby/power_assert
|
141
141
|
licenses:
|
142
|
-
- 2-
|
143
|
-
- Ruby
|
142
|
+
- BSD-2-Clause
|
143
|
+
- Ruby
|
144
144
|
metadata: {}
|
145
145
|
post_install_message:
|
146
146
|
rdoc_options:
|
147
147
|
- "--main"
|
148
|
-
- README.
|
148
|
+
- README.md
|
149
149
|
require_paths:
|
150
150
|
- lib
|
151
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.2.3
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Power Assert for Ruby
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.0.0-p648
|
5
|
-
- 2.1.10
|
6
|
-
- 2.2.10
|
7
|
-
- 2.3.8
|
8
|
-
- 2.4.9
|
9
|
-
- 2.5.7
|
10
|
-
- 2.6.5
|
11
|
-
- 2.7.0
|
12
|
-
- ruby-head
|
13
|
-
env:
|
14
|
-
- TEST_SYMLINK="no"
|
15
|
-
- TEST_SYMLINK="yes"
|
16
|
-
matrix:
|
17
|
-
allow_failures:
|
18
|
-
- rvm: ruby-head
|
19
|
-
before_script:
|
20
|
-
- bundle exec rake before_script
|
21
|
-
after_script:
|
22
|
-
- bundle exec rake after_script
|
data/README.rdoc
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
= power_assert
|
2
|
-
== About
|
3
|
-
Power Assert for Ruby.
|
4
|
-
|
5
|
-
Power Assert shows each value of variables and method calls in the expression.
|
6
|
-
It is useful for testing, providing which value wasn't correct when the condition is not satisfied.
|
7
|
-
|
8
|
-
Failure:
|
9
|
-
assert { 3.times.to_a.include?(3) }
|
10
|
-
| | |
|
11
|
-
| | false
|
12
|
-
| [0, 1, 2]
|
13
|
-
#<Enumerator: 3:times>
|
14
|
-
|
15
|
-
== Related Projects
|
16
|
-
In general, you don't need to use this library directly.
|
17
|
-
Use following test frameworks or extensions instead.
|
18
|
-
|
19
|
-
* {test-unit}[https://github.com/test-unit/test-unit](>= 3.0.0)
|
20
|
-
* {Document}[http://test-unit.github.io/test-unit/en/Test/Unit/Assertions.html#assert-instance_method]
|
21
|
-
* {minitest-power_assert}[https://github.com/hsbt/minitest-power_assert]
|
22
|
-
* {rspec-power_assert}[https://github.com/joker1007/rspec-power_assert]
|
23
|
-
* {pry-power_assert}[https://github.com/yui-knk/pry-power_assert]
|
24
|
-
* {pry-byebug-power_assert}[https://github.com/k-tsj/pry-byebug-power_assert]
|
25
|
-
* {power_p}[https://github.com/k-tsj/power_p]
|
26
|
-
|
27
|
-
== Requirement
|
28
|
-
* CRuby 2.0.0 or later
|
29
|
-
|
30
|
-
== Reference
|
31
|
-
* {Power Assert in Ruby (at RubyKaigi 2014) // Speaker Deck}[https://speakerdeck.com/k_tsj/power-assert-in-ruby]
|
32
|
-
|
33
|
-
== Known Limitations
|
34
|
-
* Expressions must be put in one line. Expressions with folded long lines produce nothing report, e.g.:
|
35
|
-
assert do
|
36
|
-
# reported
|
37
|
-
func(foo: 0123456789, bar: "abcdefg")
|
38
|
-
end
|
39
|
-
|
40
|
-
assert do
|
41
|
-
# won't be reported
|
42
|
-
func(foo: 0123456789,
|
43
|
-
bar: "abcdefg")
|
44
|
-
end
|
45
|
-
* Expressions must have one or more method call. Expressions with no method call produce nothing report, e.g.:
|
46
|
-
val = false
|
47
|
-
assert do
|
48
|
-
# reported
|
49
|
-
val == true
|
50
|
-
end
|
51
|
-
|
52
|
-
assert do
|
53
|
-
# won't be reported
|
54
|
-
val
|
55
|
-
end
|
56
|
-
* Returned values from accessor methods, method missing, or "super" produce nothing report, e.g:
|
57
|
-
class Foo
|
58
|
-
attr_accessor :val
|
59
|
-
end
|
60
|
-
foo = Foo.new
|
61
|
-
foo.val = false
|
62
|
-
|
63
|
-
assert do
|
64
|
-
# reported (only the value of "foo" and the literal "true")
|
65
|
-
foo.val == true
|
66
|
-
end
|
67
|
-
|
68
|
-
assert do
|
69
|
-
# won't be reported
|
70
|
-
foo.val
|
71
|
-
end
|
72
|
-
* Expressions should not have conditional branches. Expressions with such conditional codes may produce nothing report, e.g.:
|
73
|
-
condition = true
|
74
|
-
expected = false
|
75
|
-
actual = true
|
76
|
-
assert do
|
77
|
-
# this will fail but nothing reported
|
78
|
-
condition ? expected == actual : expected == actual
|
79
|
-
end
|
80
|
-
|
81
|
-
== Travis Build Status {<img src="https://secure.travis-ci.org/ruby/power_assert.png?branch=master"/>}[http://travis-ci.org/ruby/power_assert]
|