yard-doctest 0.1.5 → 0.1.6
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/CHANGELOG.md +29 -0
- data/LICENSE.txt +1 -1
- data/README.md +5 -1
- data/features/yard-doctest.feature +32 -2
- data/lib/yard/doctest/example.rb +13 -3
- data/lib/yard/doctest/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396c212a7f20383346628549f84472faa0bb150b
|
4
|
+
data.tar.gz: abb37e7c096350ef190fef1084d448f117f0ab75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee6657e890518cd8f8f72c164c3802f7db7f61e2ac4b8dcb5d283ea056cba27af3cf55e22e08471bd31e5475bdf90ef9a5d455788446937856927b2762a1445c
|
7
|
+
data.tar.gz: 2831f3ed0dad1391fcfb5a700792ccaefade4ca27e3d744b0735f8486b2cf9673066440c2fae126b9cd44988bbdfae92cd919f49f2985177b450679487cac545
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
## 0.1.6
|
2
|
+
|
3
|
+
* Support per-example hooks [#3](https://github.com/p0deje/yard-doctest/pull/3)
|
4
|
+
|
5
|
+
## 0.1.5
|
6
|
+
|
7
|
+
* Support testing for exceptions [#2](https://github.com/p0deje/yard-doctest/pull/2)
|
8
|
+
|
9
|
+
## 0.1.4
|
10
|
+
|
11
|
+
* Allow to keep doctest_helper in support/ directory
|
12
|
+
|
13
|
+
## 0.1.3
|
14
|
+
|
15
|
+
* Rake task exits with non-zero code when doctests fail
|
16
|
+
|
17
|
+
## 0.1.2
|
18
|
+
|
19
|
+
* Allow skipping tests
|
20
|
+
* Allow configuring yard-doctest
|
21
|
+
* Rename helper from yard-doctest_helper to doctest_helper
|
22
|
+
|
23
|
+
## 0.1.1
|
24
|
+
|
25
|
+
* Refactoring
|
26
|
+
|
27
|
+
## 0.1.0
|
28
|
+
|
29
|
+
* Initial version
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# yard-doctest [](http://badge.fury.io/rb/yard-doctest) [](http://badge.fury.io/rb/yard-doctest) [](https://travis-ci.org/p0deje/yard-doctest)
|
2
2
|
|
3
3
|
Have you ever wanted to turn your amazing code examples into something that really make sense, is always up-to-date and bullet-proof? Were looking at an amazing [Python doctest](https://docs.python.org/3/library/doctest.html)? Well, look no longer!
|
4
4
|
|
@@ -289,6 +289,10 @@ YARD::Doctest.configure do |doctest|
|
|
289
289
|
doctest.after('MyClass#foo') do
|
290
290
|
# this will only be called for doctests of `MyClass#foo`
|
291
291
|
end
|
292
|
+
|
293
|
+
doctest.before('MyClass#foo@Example one') do
|
294
|
+
# this will only be called for example `Example one` of `MyClass#foo`
|
295
|
+
end
|
292
296
|
end
|
293
297
|
```
|
294
298
|
|
@@ -124,8 +124,12 @@ Feature: yard doctest
|
|
124
124
|
When I run `bundle exec yard doctest`
|
125
125
|
Then the output should contain:
|
126
126
|
"""
|
127
|
-
|
128
|
-
|
127
|
+
--- expected
|
128
|
+
+++ actual
|
129
|
+
@@ -1 +1,2 @@
|
130
|
+
-2
|
131
|
+
+# encoding: US-ASCII
|
132
|
+
+"2"
|
129
133
|
"""
|
130
134
|
|
131
135
|
Scenario: asserts exceptions
|
@@ -494,6 +498,32 @@ Feature: yard doctest
|
|
494
498
|
When I run `bundle exec yard doctest`
|
495
499
|
Then the output should contain "2 runs, 2 assertions, 0 failures, 0 errors, 0 skips"
|
496
500
|
|
501
|
+
Scenario: supports test-name hooks for multiple examples on the same code object
|
502
|
+
Given a file named "doctest_helper.rb" with:
|
503
|
+
"""
|
504
|
+
require 'app/app'
|
505
|
+
|
506
|
+
YARD::Doctest.before('#flag') do
|
507
|
+
@flag = true
|
508
|
+
end
|
509
|
+
|
510
|
+
YARD::Doctest.before('#flag@Second example for flag') do
|
511
|
+
@flag = false
|
512
|
+
end
|
513
|
+
"""
|
514
|
+
And a file named "app/app.rb" with:
|
515
|
+
"""
|
516
|
+
# @example
|
517
|
+
# flag #=> true
|
518
|
+
# @example Second example for flag
|
519
|
+
# flag #=> false
|
520
|
+
def flag
|
521
|
+
@flag
|
522
|
+
end
|
523
|
+
"""
|
524
|
+
When I run `bundle exec yard doctest`
|
525
|
+
Then the output should contain "2 runs, 2 assertions, 0 failures, 0 errors, 0 skips"
|
526
|
+
|
497
527
|
Scenario: can skip tests
|
498
528
|
Given a file named "doctest_helper.rb" with:
|
499
529
|
"""
|
data/lib/yard/doctest/example.rb
CHANGED
@@ -26,7 +26,15 @@ module YARD
|
|
26
26
|
|
27
27
|
return if YARD::Doctest.skips.any? { |skip| this.definition.include?(skip) }
|
28
28
|
describe this.definition do
|
29
|
-
|
29
|
+
# Append this.name to this.definition if YARD's @example tag is followed by
|
30
|
+
# descriptive text, to support hooks for multiple examples per code object.
|
31
|
+
example_name = if this.name.empty?
|
32
|
+
this.definition
|
33
|
+
else
|
34
|
+
"#{this.definition}@#{this.name}"
|
35
|
+
end
|
36
|
+
|
37
|
+
register_hooks(example_name, YARD::Doctest.hooks)
|
30
38
|
|
31
39
|
it this.name do
|
32
40
|
this.asserts.each do |assert|
|
@@ -65,12 +73,14 @@ module YARD
|
|
65
73
|
exception.set_backtrace backtrace
|
66
74
|
end
|
67
75
|
|
68
|
-
|
76
|
+
|
77
|
+
|
78
|
+
def self.register_hooks(example_name, all_hooks)
|
69
79
|
all_hooks.each do |type, hooks|
|
70
80
|
hooks.each do |hook|
|
71
81
|
if hook[:test]
|
72
82
|
# test-name hooks
|
73
|
-
send(type, &hook[:block]) if
|
83
|
+
send(type, &hook[:block]) if example_name.include?(hook[:test])
|
74
84
|
else
|
75
85
|
# global hooks
|
76
86
|
send(type, &hook[:block])
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -88,6 +88,7 @@ extra_rdoc_files: []
|
|
88
88
|
files:
|
89
89
|
- ".gitignore"
|
90
90
|
- ".travis.yml"
|
91
|
+
- CHANGELOG.md
|
91
92
|
- Gemfile
|
92
93
|
- LICENSE.txt
|
93
94
|
- README.md
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.4.5.1
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Doctests from YARD examples
|