yard-doctest 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/features/yard-doctest.feature +22 -0
- data/lib/yard/doctest/example.rb +19 -8
- data/lib/yard/doctest/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: 0cd1fc903edfa86337db79cf3b40f762fbf2cadc
|
4
|
+
data.tar.gz: 408b814a356c164e4d894f1c9320ce422ffb8706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fba50d53837f55aef654d3e675ff8b3bca2128668f2599db051c0f4e0c1d11c4c9a1bb1b6d1b7fa697eff0c930675aea6f0e885336a70dc6db3cfc6db64e508
|
7
|
+
data.tar.gz: c1b06e9a0119434cc69a5212a7d06982e69adfa2d1e025513299fc50646c5158a81d209341237ec3945c774386616c0a88089ab0d2d90dee2bd4d07c6c0b8744
|
data/CHANGELOG.md
CHANGED
@@ -108,6 +108,28 @@ Feature: yard doctest
|
|
108
108
|
And the output should contain "B.multiply"
|
109
109
|
And the output should contain "B#div"
|
110
110
|
|
111
|
+
Scenario: fails if exception is raised
|
112
|
+
Given a file named "doctest_helper.rb" with:
|
113
|
+
"""
|
114
|
+
require 'app/app'
|
115
|
+
"""
|
116
|
+
And a file named "app/app.rb" with:
|
117
|
+
"""
|
118
|
+
# @example
|
119
|
+
# foo
|
120
|
+
def foo
|
121
|
+
raise 'Fails with exception'
|
122
|
+
end
|
123
|
+
"""
|
124
|
+
When I run `bundle exec yard doctest`
|
125
|
+
Then the exit status should be 1
|
126
|
+
And the output should contain:
|
127
|
+
"""
|
128
|
+
1) Error:
|
129
|
+
#foo#test_0001_:
|
130
|
+
RuntimeError: Fails with exception
|
131
|
+
"""
|
132
|
+
|
111
133
|
Scenario: asserts using equality
|
112
134
|
Given a file named "doctest_helper.rb" with:
|
113
135
|
"""
|
data/lib/yard/doctest/example.rb
CHANGED
@@ -39,13 +39,10 @@ module YARD
|
|
39
39
|
it this.name do
|
40
40
|
this.asserts.each do |assert|
|
41
41
|
expected, actual = assert[:expected], assert[:actual]
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
rescue Minitest::Assertion => error
|
47
|
-
add_filepath_to_backtrace(error, this.filepath)
|
48
|
-
raise error
|
42
|
+
if expected.empty?
|
43
|
+
evaluate_example(this, actual)
|
44
|
+
else
|
45
|
+
assert_example(this, expected, actual)
|
49
46
|
end
|
50
47
|
end
|
51
48
|
end
|
@@ -55,6 +52,20 @@ module YARD
|
|
55
52
|
|
56
53
|
protected
|
57
54
|
|
55
|
+
def evaluate_example(example, actual)
|
56
|
+
context.eval(actual)
|
57
|
+
rescue StandardError => error
|
58
|
+
add_filepath_to_backtrace(error, example.filepath)
|
59
|
+
raise error
|
60
|
+
end
|
61
|
+
|
62
|
+
def assert_example(example, expected, actual)
|
63
|
+
assert_equal evaluate(expected), evaluate(actual)
|
64
|
+
rescue Minitest::Assertion => error
|
65
|
+
add_filepath_to_backtrace(error, example.filepath)
|
66
|
+
raise error
|
67
|
+
end
|
68
|
+
|
58
69
|
def evaluate(code)
|
59
70
|
context.eval(code)
|
60
71
|
rescue StandardError => error
|
@@ -69,7 +80,7 @@ module YARD
|
|
69
80
|
backtrace = exception.backtrace
|
70
81
|
line = backtrace.find { |l| l =~ %r{lib/yard/doctest/example} }
|
71
82
|
index = backtrace.index(line)
|
72
|
-
backtrace = backtrace.insert(index, filepath)
|
83
|
+
backtrace = backtrace.insert(index + 1, filepath)
|
73
84
|
exception.set_backtrace backtrace
|
74
85
|
end
|
75
86
|
|
data/lib/yard/doctest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-doctest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|