yard-doctest 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4023ce3acc9d083c21073b13aa9e38aa70106ed0
4
- data.tar.gz: 4e839b3a471e0639ca5e217557e176abe5a6d2ff
3
+ metadata.gz: 0cd1fc903edfa86337db79cf3b40f762fbf2cadc
4
+ data.tar.gz: 408b814a356c164e4d894f1c9320ce422ffb8706
5
5
  SHA512:
6
- metadata.gz: 9ca5d6326dfab02d4bc4d2c391f23aeb7f8d92f56d29d26269a3784ebdfc123b33edfd1b1ab68a1d64da0e84cad1b42be90353c09cff9bdc9117d8330b2350ff
7
- data.tar.gz: 6c62c7630f36fb14dd7b834fec7a75cde72b0c13131c6c9702aabb679e2058e1f4585310dfa2ed554d5c6bc216b349a4a7c171807bd4eb17c4bf706332bca068
6
+ metadata.gz: 0fba50d53837f55aef654d3e675ff8b3bca2128668f2599db051c0f4e0c1d11c4c9a1bb1b6d1b7fa697eff0c930675aea6f0e885336a70dc6db3cfc6db64e508
7
+ data.tar.gz: c1b06e9a0119434cc69a5212a7d06982e69adfa2d1e025513299fc50646c5158a81d209341237ec3945c774386616c0a88089ab0d2d90dee2bd4d07c6c0b8744
@@ -1,3 +1,7 @@
1
+ ## 0.1.8
2
+
3
+ * Fixed a bug when test was passing even though exception was raised in example
4
+
1
5
  ## 0.1.7
2
6
 
3
7
  * Fix a bug when only one of global and test-name hooks is executed for matching test
@@ -108,6 +108,28 @@ Feature: yard doctest
108
108
  And the output should contain "B.multiply"
109
109
  And the output should contain "B#div"
110
110
 
111
+ Scenario: fails if exception is raised
112
+ Given a file named "doctest_helper.rb" with:
113
+ """
114
+ require 'app/app'
115
+ """
116
+ And a file named "app/app.rb" with:
117
+ """
118
+ # @example
119
+ # foo
120
+ def foo
121
+ raise 'Fails with exception'
122
+ end
123
+ """
124
+ When I run `bundle exec yard doctest`
125
+ Then the exit status should be 1
126
+ And the output should contain:
127
+ """
128
+ 1) Error:
129
+ #foo#test_0001_:
130
+ RuntimeError: Fails with exception
131
+ """
132
+
111
133
  Scenario: asserts using equality
112
134
  Given a file named "doctest_helper.rb" with:
113
135
  """
@@ -39,13 +39,10 @@ module YARD
39
39
  it this.name do
40
40
  this.asserts.each do |assert|
41
41
  expected, actual = assert[:expected], assert[:actual]
42
- next if expected.empty?
43
-
44
- begin
45
- assert_equal evaluate(expected), evaluate(actual)
46
- rescue Minitest::Assertion => error
47
- add_filepath_to_backtrace(error, this.filepath)
48
- raise error
42
+ if expected.empty?
43
+ evaluate_example(this, actual)
44
+ else
45
+ assert_example(this, expected, actual)
49
46
  end
50
47
  end
51
48
  end
@@ -55,6 +52,20 @@ module YARD
55
52
 
56
53
  protected
57
54
 
55
+ def evaluate_example(example, actual)
56
+ context.eval(actual)
57
+ rescue StandardError => error
58
+ add_filepath_to_backtrace(error, example.filepath)
59
+ raise error
60
+ end
61
+
62
+ def assert_example(example, expected, actual)
63
+ assert_equal evaluate(expected), evaluate(actual)
64
+ rescue Minitest::Assertion => error
65
+ add_filepath_to_backtrace(error, example.filepath)
66
+ raise error
67
+ end
68
+
58
69
  def evaluate(code)
59
70
  context.eval(code)
60
71
  rescue StandardError => error
@@ -69,7 +80,7 @@ module YARD
69
80
  backtrace = exception.backtrace
70
81
  line = backtrace.find { |l| l =~ %r{lib/yard/doctest/example} }
71
82
  index = backtrace.index(line)
72
- backtrace = backtrace.insert(index, filepath)
83
+ backtrace = backtrace.insert(index + 1, filepath)
73
84
  exception.set_backtrace backtrace
74
85
  end
75
86
 
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module Doctest
3
- VERSION = '0.1.7'
3
+ VERSION = '0.1.8'
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.7
4
+ version: 0.1.8
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-10-04 00:00:00.000000000 Z
11
+ date: 2016-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard