yard-doctest 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29e48bebd491242d186f47e8e22d2a47733f3589
4
- data.tar.gz: b0f16f022adbd8e1340b243d677e51e124c3d58f
3
+ metadata.gz: e060a6fdecfeb740798431f7a26212efb2565771
4
+ data.tar.gz: 3f4c8f9c7a9ab960a26e3b10dba993cb6c5bbb5c
5
5
  SHA512:
6
- metadata.gz: c64f734aecad92a6e23f5ab0ebc6d50068d7a863074abf22e9689cd7d350b5483cb03a3f588ded8ce037cd88f4fe5171ff491bcd4882ab43c132a18bc58421fa
7
- data.tar.gz: 64798db18bf07febd134ecaa32c17dc1b9bdbd7ee17a8d12e630311a3c5666fb209b907d452decca5727a0587879fedf9d4744b82160f9ccdeaff6dd74080cfe
6
+ metadata.gz: aaee894607b41aa9a01378fe6b1eeda09058512a37a6687180a96788c3e0f204863c0afd1c34929f0c09e3dd3f322d6c44eecf7dc29491ddfa45a5c86b06a977
7
+ data.tar.gz: dd6f612d02bdddd778cc8bb4315dca7e4928149697a8331ed0106a1f81ec0d8d52ea8b8130eb9aa1a6e8cbf918f600e3ec88d9e7a32ed8a5059cfa3c864aba45
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.11
2
+
3
+ * Remove constants defined during test execution for better isolation.
4
+
1
5
  ## 0.1.10
2
6
 
3
7
  * Properly share local context between assertions when scoped to class (#6)
@@ -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
- Scenario: allow 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
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
- When I run `bundle exec yard doctest`
626
- Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips"
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"
@@ -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] }
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module Doctest
3
- VERSION = '0.1.10'
3
+ VERSION = '0.1.11'
4
4
  end
5
5
  end
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.10
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: 2017-05-23 00:00:00.000000000 Z
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.5.2
124
+ rubygems_version: 2.6.13
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Doctests from YARD examples