power_assert 1.1.6 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +32 -0
- data/README.md +98 -0
- 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/lib/power_assert.rb +3 -10
- data/power_assert.gemspec +7 -7
- metadata +16 -18
- data/.travis.yml +0 -22
- data/README.rdoc +0 -81
- data/bin/console +0 -12
- data/bin/setup +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28b26a04c7891b2d3bf6f71b23936f90fac854304434bafda19329cb5eb8785f
|
4
|
+
data.tar.gz: 47650e43f13d7ee72a1e5dc4452f328fd1e75791ec8b80622b8130afd79aaa30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343d98448f071de39eeb7f9ff71497726bbeb50c8c707f665c3f0aa8ba1696fed698a2f27f930e1d50be65bc40c1210cfe9f0c7306cc40ea780a1dc88a09d73e
|
7
|
+
data.tar.gz: 842e379a4c2a965c4a2d3704bed2b4a4ba505d52086d52cb1cd706b41429096c9a3078eecf01b8b59175dedb4f1dd9c30f5d8dcc46d47969c1d6abd29fa47172
|
@@ -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,98 @@
|
|
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
|
+
* [rspec-matchers-power_assert_matchers](https://github.com/kachick/rspec-matchers-power_assert_matchers)
|
22
|
+
* [pry-power_assert](https://github.com/yui-knk/pry-power_assert)
|
23
|
+
* [pry-byebug-power_assert](https://github.com/k-tsj/pry-byebug-power_assert)
|
24
|
+
* [irb-power_assert](https://github.com/kachick/irb-power_assert)
|
25
|
+
* [power_p](https://github.com/k-tsj/power_p)
|
26
|
+
|
27
|
+
## Requirement
|
28
|
+
* CRuby 2.5+
|
29
|
+
|
30
|
+
## Configuration
|
31
|
+
To colorize output messages, add <code>require "power_assert/colorize"</code> to your code.
|
32
|
+
(It requires CRuby 3.0.1+ or irb 1.3.1+)
|
33
|
+
|
34
|
+
## Known Limitations
|
35
|
+
* Expressions must be put in one line. Expressions with folded long lines produce nothing report, e.g.:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
assert do
|
39
|
+
# reported
|
40
|
+
func(foo: 0123456789, bar: "abcdefg")
|
41
|
+
end
|
42
|
+
|
43
|
+
assert do
|
44
|
+
# won't be reported
|
45
|
+
func(foo: 0123456789,
|
46
|
+
bar: "abcdefg")
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
* Expressions must have one or more method call. Expressions with no method call produce nothing report, e.g.:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
val = false
|
54
|
+
assert do
|
55
|
+
# reported
|
56
|
+
val == true
|
57
|
+
end
|
58
|
+
|
59
|
+
assert do
|
60
|
+
# won't be reported
|
61
|
+
val
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
* Returned values from accessor methods, method missing, or "super" produce nothing report, e.g:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
class Foo
|
69
|
+
attr_accessor :val
|
70
|
+
end
|
71
|
+
foo = Foo.new
|
72
|
+
foo.val = false
|
73
|
+
|
74
|
+
assert do
|
75
|
+
# reported (only the value of "foo" and the literal "true")
|
76
|
+
foo.val == true
|
77
|
+
end
|
78
|
+
|
79
|
+
assert do
|
80
|
+
# won't be reported
|
81
|
+
foo.val
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
* Expressions should not have conditional branches. Expressions with such conditional codes may produce nothing report, e.g.:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
condition = true
|
89
|
+
expected = false
|
90
|
+
actual = true
|
91
|
+
assert do
|
92
|
+
# this will fail but nothing reported
|
93
|
+
condition ? expected == actual : expected == actual
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
## Reference
|
98
|
+
* [Power Assert in Ruby (at RubyKaigi 2014) // Speaker Deck](https://speakerdeck.com/k_tsj/power-assert-in-ruby)
|
@@ -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/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)
|
data/power_assert.gemspec
CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = PowerAssert::VERSION
|
9
9
|
s.authors = ['Kazuki Tsujimoto']
|
10
10
|
s.email = ['kazuki@callcc.net']
|
11
|
-
s.homepage = 'https://github.com/
|
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
|
-
f.match(%r{
|
16
|
+
f.match(%r{\A(?:test|spec|features|benchmark|bin)/})
|
17
17
|
end
|
18
18
|
s.bindir = 'exe'
|
19
19
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -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.1
|
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-08-29 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,26 +108,24 @@ 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
|
-
- bin/console
|
130
|
-
- bin/setup
|
131
129
|
- lib/power_assert.rb
|
132
130
|
- lib/power_assert/colorize.rb
|
133
131
|
- lib/power_assert/configuration.rb
|
@@ -137,15 +135,15 @@ files:
|
|
137
135
|
- lib/power_assert/parser.rb
|
138
136
|
- lib/power_assert/version.rb
|
139
137
|
- power_assert.gemspec
|
140
|
-
homepage: https://github.com/
|
138
|
+
homepage: https://github.com/ruby/power_assert
|
141
139
|
licenses:
|
142
|
-
- 2-
|
143
|
-
- Ruby
|
140
|
+
- BSD-2-Clause
|
141
|
+
- Ruby
|
144
142
|
metadata: {}
|
145
143
|
post_install_message:
|
146
144
|
rdoc_options:
|
147
145
|
- "--main"
|
148
|
-
- README.
|
146
|
+
- README.md
|
149
147
|
require_paths:
|
150
148
|
- lib
|
151
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -159,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
157
|
- !ruby/object:Gem::Version
|
160
158
|
version: '0'
|
161
159
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.3.0.dev
|
163
161
|
signing_key:
|
164
162
|
specification_version: 4
|
165
163
|
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/k-tsj/power_assert.png?branch=master"/>}[http://travis-ci.org/k-tsj/power_assert]
|
data/bin/console
DELETED