yard-doctest 0.1.9 → 0.1.10

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: 47ff35130e3241348736458652887da1bca96512
4
- data.tar.gz: 76d18f3e48943bab0d1058082291d98fc3167477
3
+ metadata.gz: 29e48bebd491242d186f47e8e22d2a47733f3589
4
+ data.tar.gz: b0f16f022adbd8e1340b243d677e51e124c3d58f
5
5
  SHA512:
6
- metadata.gz: 00f1a7d01a6f625d858f275e6356f223d7af8487fe4faaafdd36f1e98fcd4193f8b20754ee332196a9df8878f1005cf269ef41ca634dbf16bba53437517a4711
7
- data.tar.gz: 4f29c14960eb13d008ae1ef5ab97dbe763441c7d38b6bfee8064c529d160083d832f3b78c8548e0fc329773ab88eae0efee6e984c908d3c10960fcbf29c05845
6
+ metadata.gz: c64f734aecad92a6e23f5ab0ebc6d50068d7a863074abf22e9689cd7d350b5483cb03a3f588ded8ce037cd88f4fe5171ff491bcd4882ab43c132a18bc58421fa
7
+ data.tar.gz: 64798db18bf07febd134ecaa32c17dc1b9bdbd7ee17a8d12e630311a3c5666fb209b907d452decca5727a0587879fedf9d4744b82160f9ccdeaff6dd74080cfe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.10
2
+
3
+ * Properly share local context between assertions when scoped to class (#6)
4
+
1
5
  ## 0.1.9
2
6
 
3
7
  * Allow to have `doctest_helper.rb` in `spec/` directory [#4](https://github.com/p0deje/yard-doctest/pull/4)
@@ -442,9 +442,18 @@ Feature: yard doctest
442
442
  def sum(one, two)
443
443
  one + two
444
444
  end
445
+
446
+ module App
447
+ # @example
448
+ # src = {foo: 'bar'}
449
+ # src[:foo] #=> 'bar'
450
+ # src[:foo] #=> 'bar'
451
+ def foo
452
+ end
453
+ end
445
454
  """
446
455
  When I run `bundle exec yard doctest`
447
- Then the output should contain "1 runs, 2 assertions, 0 failures, 0 errors, 0 skips"
456
+ Then the output should contain "2 runs, 4 assertions, 0 failures, 0 errors, 0 skips"
448
457
 
449
458
  Scenario: does not share binding between examples
450
459
  Given a file named "doctest_helper.rb" with:
@@ -60,25 +60,32 @@ module YARD
60
60
  protected
61
61
 
62
62
  def evaluate_example(example, actual, bind)
63
- (bind || context).send(:eval, actual)
63
+ evaluate(actual, bind)
64
64
  rescue StandardError => error
65
65
  add_filepath_to_backtrace(error, example.filepath)
66
66
  raise error
67
67
  end
68
68
 
69
69
  def assert_example(example, expected, actual, bind)
70
- assert_equal evaluate(expected, bind), evaluate(actual, bind)
70
+ assert_equal(evaluate_with_assertion(expected, bind),
71
+ evaluate_with_assertion(actual, bind))
71
72
  rescue Minitest::Assertion => error
72
73
  add_filepath_to_backtrace(error, example.filepath)
73
74
  raise error
74
75
  end
75
76
 
76
- def evaluate(code, bind)
77
- (bind || context).send(:eval, code)
77
+ def evaluate_with_assertion(code, bind)
78
+ evaluate(code, bind)
78
79
  rescue StandardError => error
79
80
  "#<#{error.class}: #{error}>"
80
81
  end
81
82
 
83
+ def evaluate(code, bind)
84
+ context.eval code
85
+ rescue NameError
86
+ bind ? bind.__send__(:eval, code) : raise
87
+ end
88
+
82
89
  def context
83
90
  @binding ||= binding
84
91
  end
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module Doctest
3
- VERSION = '0.1.9'
3
+ VERSION = '0.1.10'
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.9
4
+ version: 0.1.10
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-01-23 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard