yard-doctest 0.1.10 → 0.1.11
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 +39 -17
- data/lib/yard/doctest/example.rb +8 -0
- data/lib/yard/doctest/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e060a6fdecfeb740798431f7a26212efb2565771
|
4
|
+
data.tar.gz: 3f4c8f9c7a9ab960a26e3b10dba993cb6c5bbb5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaee894607b41aa9a01378fe6b1eeda09058512a37a6687180a96788c3e0f204863c0afd1c34929f0c09e3dd3f322d6c44eecf7dc29491ddfa45a5c86b06a977
|
7
|
+
data.tar.gz: dd6f612d02bdddd778cc8bb4315dca7e4928149697a8331ed0106a1f81ec0d8d52ea8b8130eb9aa1a6e8cbf918f600e3ec88d9e7a32ed8a5059cfa3c864aba45
|
data/CHANGELOG.md
CHANGED
@@ -606,21 +606,43 @@ Feature: yard doctest
|
|
606
606
|
When I run `bundle exec yard doctest`
|
607
607
|
Then the output should contain "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips"
|
608
608
|
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
end
|
609
|
+
Scenario: allows binding to local context
|
610
|
+
Given a file named "doctest_helper.rb" with:
|
611
|
+
"""
|
612
|
+
require 'app/app'
|
613
|
+
"""
|
614
|
+
And a file named "app/app.rb" with:
|
615
|
+
"""
|
616
|
+
class App
|
617
|
+
# @example
|
618
|
+
# a, b = 1, 2
|
619
|
+
# sum(a, b) #=> 3
|
620
|
+
def self.sum(one, two)
|
621
|
+
one + two
|
623
622
|
end
|
624
|
-
|
625
|
-
|
626
|
-
|
623
|
+
end
|
624
|
+
"""
|
625
|
+
When I run `bundle exec yard doctest`
|
626
|
+
Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips"
|
627
|
+
|
628
|
+
Scenario: isolates constants per test
|
629
|
+
Given a file named "doctest_helper.rb" with:
|
630
|
+
"""
|
631
|
+
require 'app/app'
|
632
|
+
"""
|
633
|
+
And a file named "app/app.rb" with:
|
634
|
+
"""
|
635
|
+
# @example
|
636
|
+
# ::FOO = 123
|
637
|
+
# ::FOO #=> 123
|
638
|
+
# ::BAR #=> raise NameError, 'uninitialized constant BAR'
|
639
|
+
#
|
640
|
+
# @example
|
641
|
+
# ::BAR = 123
|
642
|
+
# ::BAR #=> 123
|
643
|
+
# ::FOO #=> raise NameError, 'uninitialized constant FOO'
|
644
|
+
class App
|
645
|
+
end
|
646
|
+
"""
|
647
|
+
When I run `bundle exec yard doctest`
|
648
|
+
Then the output should contain "2 runs, 4 assertions, 0 failures, 0 errors, 0 skips"
|
data/lib/yard/doctest/example.rb
CHANGED
@@ -44,6 +44,7 @@ module YARD
|
|
44
44
|
register_hooks(example_name, YARD::Doctest.hooks)
|
45
45
|
|
46
46
|
it this.name do
|
47
|
+
constants = Object.constants
|
47
48
|
this.asserts.each do |assert|
|
48
49
|
expected, actual = assert[:expected], assert[:actual]
|
49
50
|
if expected.empty?
|
@@ -52,6 +53,7 @@ module YARD
|
|
52
53
|
assert_example(this, expected, actual, scope)
|
53
54
|
end
|
54
55
|
end
|
56
|
+
clear_extra_constants(constants)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -98,6 +100,12 @@ module YARD
|
|
98
100
|
exception.set_backtrace backtrace
|
99
101
|
end
|
100
102
|
|
103
|
+
def clear_extra_constants(constants)
|
104
|
+
(Object.constants - constants).each do |constant|
|
105
|
+
Object.__send__(:remove_const, constant)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
101
109
|
def self.register_hooks(example_name, all_hooks)
|
102
110
|
all_hooks.each do |type, hooks|
|
103
111
|
global_hooks = hooks.select { |hook| !hook[:test] }
|
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.11
|
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: 2018-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.6.13
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Doctests from YARD examples
|