power_assert 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +0 -1
- data/lib/power_assert.rb +10 -3
- data/lib/power_assert/context.rb +10 -5
- data/lib/power_assert/parser.rb +1 -1
- data/lib/power_assert/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c2656987c0dd57b4eaccc2309d1b5f9c4eac0d3
|
4
|
+
data.tar.gz: 04d870b66c36f4ba7beba83c3a0a764f27ee9da5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea20c40cb70c29ad969f89e39a5e9d9974a2e3e3102d62dc04e0c817f91acb51b10c0bdeaadf88a7577ce8cfc5f2392894b3f156c0bf4f587386109b47f29b11
|
7
|
+
data.tar.gz: 196d7ce2dbfb15a2b08a117d7bdb760dc40b9c437902fd1c5a0a1a1ae8c8e07ea8fb9101e9c791f32e2002ce0c4c81c10dad1831eff2b7dc7adc44f86881abe4
|
data/README.rdoc
CHANGED
@@ -7,7 +7,6 @@ It is useful for testing, providing which value wasn't correct when the conditio
|
|
7
7
|
|
8
8
|
== Related Projects
|
9
9
|
* {test-unit}[https://github.com/test-unit/test-unit](>= 3.0.0)
|
10
|
-
* {test-unit-power_assert}[https://github.com/k-tsj/test-unit-power_assert]
|
11
10
|
* {minitest-power_assert}[https://github.com/hsbt/minitest-power_assert]
|
12
11
|
* {pry-power_assert}[https://github.com/yui-knk/pry-power_assert]
|
13
12
|
* {rspec-power_assert}[https://github.com/joker1007/rspec-power_assert]
|
data/lib/power_assert.rb
CHANGED
@@ -51,19 +51,26 @@ module PowerAssert
|
|
51
51
|
|
52
52
|
def app_context?
|
53
53
|
top_frame = caller_locations.drop_while {|i| i.path.start_with?(POWER_ASSERT_LIB_DIR) }.first
|
54
|
-
top_frame
|
54
|
+
top_frame and ! ignored_file?(top_frame.path)
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def ignored_file?(file)
|
60
|
-
|
61
|
-
|
60
|
+
setup_ignored_lib_dir(Byebug, :attach, 2) if defined?(Byebug)
|
61
|
+
setup_ignored_lib_dir(PryByebug, :start_with_pry_byebug, 2, Pry) if defined?(PryByebug)
|
62
62
|
IGNORED_LIB_DIRS.find do |_, dir|
|
63
63
|
file.start_with?(dir)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def setup_ignored_lib_dir(lib, mid, depth, lib_obj = lib)
|
68
|
+
unless IGNORED_LIB_DIRS.key?(lib)
|
69
|
+
IGNORED_LIB_DIRS[lib] = lib_dir(lib_obj, mid, depth)
|
70
|
+
end
|
71
|
+
rescue NameError
|
72
|
+
end
|
73
|
+
|
67
74
|
def lib_dir(obj, mid, depth)
|
68
75
|
File.expand_path('../' * depth, obj.method(mid).source_location[0])
|
69
76
|
end
|
data/lib/power_assert/context.rb
CHANGED
@@ -23,7 +23,6 @@ module PowerAssert
|
|
23
23
|
next if ! method_id_set[method_id]
|
24
24
|
next if tp.event == :c_return and
|
25
25
|
not (@parser.lineno == tp.lineno and @parser.path == tp.path)
|
26
|
-
next unless tp.binding # workaround for ruby 2.2
|
27
26
|
locs = PowerAssert.app_caller_locations
|
28
27
|
diff = locs.length - base_caller_length
|
29
28
|
if (tp.event == :c_return && diff == 1 || tp.event == :return && diff <= 2) and Thread.current == @target_thread
|
@@ -151,8 +150,10 @@ module PowerAssert
|
|
151
150
|
locs = PowerAssert.app_caller_locations
|
152
151
|
path = locs.last.path
|
153
152
|
lineno = locs.last.lineno
|
154
|
-
|
155
|
-
|
153
|
+
if File.exist?(path)
|
154
|
+
line ||= open(path).each_line.drop(lineno - 1).first
|
155
|
+
@parser = Parser.new(line, path, lineno, @assertion_proc.binding, assertion_method.to_s)
|
156
|
+
end
|
156
157
|
end
|
157
158
|
end
|
158
159
|
end
|
@@ -180,8 +181,12 @@ module PowerAssert
|
|
180
181
|
super(base.length)
|
181
182
|
path = target_frame.path
|
182
183
|
lineno = target_frame.lineno
|
183
|
-
|
184
|
-
|
184
|
+
if File.exist?(path)
|
185
|
+
line = open(path).each_line.drop(lineno - 1).first
|
186
|
+
@parser = Parser.new(line, path, lineno, binding)
|
187
|
+
else
|
188
|
+
@parser = Parser::DUMMY
|
189
|
+
end
|
185
190
|
end
|
186
191
|
|
187
192
|
def enable
|
data/lib/power_assert/parser.rb
CHANGED
@@ -212,7 +212,7 @@ module PowerAssert
|
|
212
212
|
if node.kind_of?(Branch)
|
213
213
|
prefixes = node.flat_map {|n| collect_paths(n, prefixes, 0) }
|
214
214
|
else
|
215
|
-
prefixes = prefixes.
|
215
|
+
prefixes = prefixes.map {|prefix| prefix + [node] }
|
216
216
|
end
|
217
217
|
collect_paths(idents, prefixes, index + 1)
|
218
218
|
else
|
data/lib/power_assert/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuki Tsujimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|