yard-doctest 0.1.15 → 0.1.16
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 +20 -0
- data/lib/yard/doctest/example.rb +20 -13
- data/lib/yard/doctest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c75c418a5cbe791e718cb9ba2deff5f1b187c00ae8578a79d149cda39f567d05
|
4
|
+
data.tar.gz: e48f64151a5273ddbbc8d0f8efe5327c2f7798d744473ed7ac82e0b49e1b0842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6f46775edc0057a440ae41adcc1377a2125015981ac9dc7fd8cc5481754e8f4d4289a66262b7db51489b0ef1039c6dcd12ac825700d5bd22b687f6228979722
|
7
|
+
data.tar.gz: 69cfad611e30b3f5cd1fc6f672aed1326efd330cc9e6a8a2124316541431d2adf92b0edb71a2a5404f2b0f0a11fac218eec98f1653b36cb6316b80754f1e4c6a
|
data/CHANGELOG.md
CHANGED
@@ -590,6 +590,26 @@ Feature: yard doctest
|
|
590
590
|
When I run `bundle exec yard doctest`
|
591
591
|
Then the output should contain "2 runs, 2 assertions, 0 failures, 0 errors, 0 skips"
|
592
592
|
|
593
|
+
Scenario: passes example to hooks to allow for inspection
|
594
|
+
Given a file named "doctest_helper.rb" with:
|
595
|
+
"""
|
596
|
+
YARD::Doctest.before do |example|
|
597
|
+
require example.filepath.split(':').first
|
598
|
+
end
|
599
|
+
"""
|
600
|
+
And a file named "app/app.rb" with:
|
601
|
+
"""
|
602
|
+
# @example
|
603
|
+
# App.foo #=> 'bar'
|
604
|
+
class App
|
605
|
+
def self.foo
|
606
|
+
'bar'
|
607
|
+
end
|
608
|
+
end
|
609
|
+
"""
|
610
|
+
When I run `bundle exec yard doctest`
|
611
|
+
Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips"
|
612
|
+
|
593
613
|
Scenario: can skip tests
|
594
614
|
Given a file named "doctest_helper.rb" with:
|
595
615
|
"""
|
data/lib/yard/doctest/example.rb
CHANGED
@@ -26,12 +26,6 @@ module YARD
|
|
26
26
|
|
27
27
|
return if YARD::Doctest.skips.any? { |skip| this.definition.include?(skip) }
|
28
28
|
|
29
|
-
begin
|
30
|
-
object_name = this.definition.split(/#|\./).first
|
31
|
-
scope = Object.const_get(object_name) if const_defined?(object_name)
|
32
|
-
rescue NameError
|
33
|
-
end
|
34
|
-
|
35
29
|
describe this.definition do
|
36
30
|
# Append this.name to this.definition if YARD's @example tag is followed by
|
37
31
|
# descriptive text, to support hooks for multiple examples per code object.
|
@@ -41,9 +35,15 @@ module YARD
|
|
41
35
|
"#{this.definition}@#{this.name}"
|
42
36
|
end
|
43
37
|
|
44
|
-
register_hooks(example_name, YARD::Doctest.hooks)
|
38
|
+
register_hooks(example_name, YARD::Doctest.hooks, this)
|
45
39
|
|
46
40
|
it this.name do
|
41
|
+
begin
|
42
|
+
object_name = this.definition.split(/#|\./).first
|
43
|
+
scope = Object.const_get(object_name) if self.class.const_defined?(object_name)
|
44
|
+
rescue NameError
|
45
|
+
end
|
46
|
+
|
47
47
|
global_constants = Object.constants
|
48
48
|
scope_constants = scope.constants if scope
|
49
49
|
this.asserts.each do |assert|
|
@@ -140,12 +140,19 @@ module YARD
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
143
|
+
class << self
|
144
|
+
protected
|
145
|
+
|
146
|
+
# @param [String] example_name The name of the example.
|
147
|
+
# @param [Hash<Symbol, Array<Hash<(test: String, block: Proc)>>] all_hooks
|
148
|
+
# @param [Example] example
|
149
|
+
def register_hooks(example_name, all_hooks, example)
|
150
|
+
all_hooks.each do |type, hooks|
|
151
|
+
global_hooks = hooks.reject { |hook| hook[:test] }
|
152
|
+
test_hooks = hooks.select { |hook| hook[:test] && example_name.include?(hook[:test]) }
|
153
|
+
__send__(type) do
|
154
|
+
(global_hooks + test_hooks).each { |hook| instance_exec(example, &hook[:block]) }
|
155
|
+
end
|
149
156
|
end
|
150
157
|
end
|
151
158
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|