pry-test 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pry-test/test.rb +0 -14
- data/lib/pry-test/test_wrapper.rb +29 -20
- data/lib/pry-test/version.rb +1 -1
- data/test/test_test.rb +0 -6
- 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: 1ab4536d7f94d75381a941153dae9c1901aa9719
|
4
|
+
data.tar.gz: 2cbb7a04ea59caa9f0dfe0ab52fb995cd1abd177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 110e6acb0b10ecbf5056e062d507a72d66c9a0810f9367a1a4fb3385b424acb3da71a2bdc8b8998fb6247380e00ea19f9fc0ef9b6681e1f95693e5265ca29b45
|
7
|
+
data.tar.gz: 5628e553fd90faa0f21d443dff45555ea42e4e8dff13dda9a11dc73a646da00885fd15896f8bd19f5aeb28332f1a18a41e9a9a617868efae0017b791779a3693
|
data/lib/pry-test/test.rb
CHANGED
@@ -22,22 +22,8 @@ module PryTest
|
|
22
22
|
@tests ||= []
|
23
23
|
end
|
24
24
|
|
25
|
-
# All files that define subclasses of this class.
|
26
|
-
# @note Primarily used in the context of PryTest::Test.
|
27
|
-
# @example Files are stored in a Hash with the following format.
|
28
|
-
# {
|
29
|
-
# "path/to/file1.rb" => ["line 1", "line 2", "line 3", ...],
|
30
|
-
# "path/to/file2.rb" => ["line 1", "line 2", "line 3", ...]
|
31
|
-
# }
|
32
|
-
# @return [Hash]
|
33
|
-
def files
|
34
|
-
@files ||= {}
|
35
|
-
end
|
36
|
-
|
37
25
|
# A callback provided by Ruby that is invoked whenever a subclass is created.
|
38
26
|
def inherited(subclass)
|
39
|
-
file_path = caller[0][0, caller[0].index(/:[0-9]+:/)]
|
40
|
-
files[file_path] = File.open(file_path).readlines
|
41
27
|
subclasses << subclass
|
42
28
|
end
|
43
29
|
|
@@ -59,7 +59,8 @@ module PryTest
|
|
59
59
|
# end
|
60
60
|
# end
|
61
61
|
def assert(value)
|
62
|
-
|
62
|
+
info = assert_info(value, caller_locations.first)
|
63
|
+
@asserts << info.merge(:value => value)
|
63
64
|
|
64
65
|
if !value
|
65
66
|
Pry.start unless @options[:disable_pry]
|
@@ -96,9 +97,10 @@ module PryTest
|
|
96
97
|
|
97
98
|
private
|
98
99
|
|
99
|
-
# Builds a Hash of assert information for the given call stack.
|
100
|
+
# Builds a Hash of assert information for the given assert value & call stack location.
|
100
101
|
#
|
101
|
-
# @
|
102
|
+
# @params [Boolean] value The value of assert.
|
103
|
+
# @param [Thread::Backtrace::Location] location The call stack location to extract info from.
|
102
104
|
#
|
103
105
|
# @example
|
104
106
|
# {
|
@@ -108,26 +110,33 @@ module PryTest
|
|
108
110
|
# }
|
109
111
|
#
|
110
112
|
# @return [Hash]
|
111
|
-
def assert_info(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
line_index = line_num - 1
|
116
|
-
line = lines[line_index]
|
117
|
-
{
|
118
|
-
:file_path => file_path,
|
119
|
-
:lines => lines,
|
120
|
-
:line_num => line_num,
|
121
|
-
:line => line
|
113
|
+
def assert_info(value, location)
|
114
|
+
info = {
|
115
|
+
:file_path => location.absolute_path,
|
116
|
+
:line_num => location.lineno
|
122
117
|
}
|
118
|
+
|
119
|
+
info.merge! line_info(location) unless value
|
120
|
+
info
|
123
121
|
end
|
124
122
|
|
125
|
-
#
|
126
|
-
#
|
127
|
-
# @param [
|
128
|
-
#
|
129
|
-
|
130
|
-
|
123
|
+
# Builds a Hash of line/source information for the given call stack location.
|
124
|
+
#
|
125
|
+
# @param [Thread::Backtrace::Location] location The call stack location to extract info from.
|
126
|
+
#
|
127
|
+
# @example
|
128
|
+
# {
|
129
|
+
# :lines => ["line one", "line two"]
|
130
|
+
# :line => "line two"
|
131
|
+
# }
|
132
|
+
#
|
133
|
+
# @return [Hash]
|
134
|
+
def line_info(location)
|
135
|
+
lines = File.open(location.absolute_path).readlines
|
136
|
+
{
|
137
|
+
:lines => lines,
|
138
|
+
:line => lines[location.lineno]
|
139
|
+
}
|
131
140
|
end
|
132
141
|
|
133
142
|
end
|
data/lib/pry-test/version.rb
CHANGED
data/test/test_test.rb
CHANGED
@@ -33,12 +33,6 @@ unless ENV["PRY_TEST_DEMO"]
|
|
33
33
|
assert @Example.tests.first.is_a?(PryTest::TestWrapper)
|
34
34
|
end
|
35
35
|
|
36
|
-
test "stores files" do
|
37
|
-
file = __FILE__
|
38
|
-
assert @test_test.files[file].is_a?(Array)
|
39
|
-
assert @test_test.files[file].select{ |l| l.start_with?(" assert @test_test.files[file].select{ |l| l.start_with?(") }.length > 0
|
40
|
-
end
|
41
|
-
|
42
36
|
test ".before" do
|
43
37
|
assert @Example.instance_eval { @before } == @before_callback
|
44
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|