yard-doctest 0.1.6 → 0.1.7
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 +4 -0
- data/features/yard-doctest.feature +21 -0
- data/lib/yard/doctest/example.rb +8 -14
- 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: 4023ce3acc9d083c21073b13aa9e38aa70106ed0
|
4
|
+
data.tar.gz: 4e839b3a471e0639ca5e217557e176abe5a6d2ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca5d6326dfab02d4bc4d2c391f23aeb7f8d92f56d29d26269a3784ebdfc123b33edfd1b1ab68a1d64da0e84cad1b42be90353c09cff9bdc9117d8330b2350ff
|
7
|
+
data.tar.gz: 6c62c7630f36fb14dd7b834fec7a75cde72b0c13131c6c9702aabb679e2058e1f4585310dfa2ed554d5c6bc216b349a4a7c171807bd4eb17c4bf706332bca068
|
data/CHANGELOG.md
CHANGED
@@ -498,6 +498,27 @@ Feature: yard doctest
|
|
498
498
|
When I run `bundle exec yard doctest`
|
499
499
|
Then the output should contain "2 runs, 2 assertions, 0 failures, 0 errors, 0 skips"
|
500
500
|
|
501
|
+
Scenario: supports global and test-name hooks
|
502
|
+
Given a file named "doctest_helper.rb" with:
|
503
|
+
"""
|
504
|
+
require 'app/app'
|
505
|
+
|
506
|
+
YARD::Doctest.configure do |doctest|
|
507
|
+
doctest.before { @one = true }
|
508
|
+
doctest.before('#foo') { @two = true }
|
509
|
+
end
|
510
|
+
"""
|
511
|
+
And a file named "app/app.rb" with:
|
512
|
+
"""
|
513
|
+
# @example
|
514
|
+
# foo #=> true
|
515
|
+
def foo
|
516
|
+
@one && @two
|
517
|
+
end
|
518
|
+
"""
|
519
|
+
When I run `bundle exec yard doctest`
|
520
|
+
Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips"
|
521
|
+
|
501
522
|
Scenario: supports test-name hooks for multiple examples on the same code object
|
502
523
|
Given a file named "doctest_helper.rb" with:
|
503
524
|
"""
|
data/lib/yard/doctest/example.rb
CHANGED
@@ -29,10 +29,10 @@ module YARD
|
|
29
29
|
# Append this.name to this.definition if YARD's @example tag is followed by
|
30
30
|
# descriptive text, to support hooks for multiple examples per code object.
|
31
31
|
example_name = if this.name.empty?
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
this.definition
|
33
|
+
else
|
34
|
+
"#{this.definition}@#{this.name}"
|
35
|
+
end
|
36
36
|
|
37
37
|
register_hooks(example_name, YARD::Doctest.hooks)
|
38
38
|
|
@@ -73,18 +73,12 @@ module YARD
|
|
73
73
|
exception.set_backtrace backtrace
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
76
|
def self.register_hooks(example_name, all_hooks)
|
79
77
|
all_hooks.each do |type, hooks|
|
80
|
-
hooks.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
# global hooks
|
86
|
-
send(type, &hook[:block])
|
87
|
-
end
|
78
|
+
global_hooks = hooks.select { |hook| !hook[:test] }
|
79
|
+
test_hooks = hooks.select { |hook| hook[:test] && example_name.include?(hook[:test]) }
|
80
|
+
__send__(type) do
|
81
|
+
(global_hooks + test_hooks).each { |hook| instance_exec(&hook[:block]) }
|
88
82
|
end
|
89
83
|
end
|
90
84
|
end
|
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.7
|
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-
|
11
|
+
date: 2016-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|