yard-doctest 0.1.6 → 0.1.7

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: 396c212a7f20383346628549f84472faa0bb150b
4
- data.tar.gz: abb37e7c096350ef190fef1084d448f117f0ab75
3
+ metadata.gz: 4023ce3acc9d083c21073b13aa9e38aa70106ed0
4
+ data.tar.gz: 4e839b3a471e0639ca5e217557e176abe5a6d2ff
5
5
  SHA512:
6
- metadata.gz: ee6657e890518cd8f8f72c164c3802f7db7f61e2ac4b8dcb5d283ea056cba27af3cf55e22e08471bd31e5475bdf90ef9a5d455788446937856927b2762a1445c
7
- data.tar.gz: 2831f3ed0dad1391fcfb5a700792ccaefade4ca27e3d744b0735f8486b2cf9673066440c2fae126b9cd44988bbdfae92cd919f49f2985177b450679487cac545
6
+ metadata.gz: 9ca5d6326dfab02d4bc4d2c391f23aeb7f8d92f56d29d26269a3784ebdfc123b33edfd1b1ab68a1d64da0e84cad1b42be90353c09cff9bdc9117d8330b2350ff
7
+ data.tar.gz: 6c62c7630f36fb14dd7b834fec7a75cde72b0c13131c6c9702aabb679e2058e1f4585310dfa2ed554d5c6bc216b349a4a7c171807bd4eb17c4bf706332bca068
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.7
2
+
3
+ * Fix a bug when only one of global and test-name hooks is executed for matching test
4
+
1
5
  ## 0.1.6
2
6
 
3
7
  * Support per-example hooks [#3](https://github.com/p0deje/yard-doctest/pull/3)
@@ -498,6 +498,27 @@ Feature: yard doctest
498
498
  When I run `bundle exec yard doctest`
499
499
  Then the output should contain "2 runs, 2 assertions, 0 failures, 0 errors, 0 skips"
500
500
 
501
+ Scenario: supports global and test-name hooks
502
+ Given a file named "doctest_helper.rb" with:
503
+ """
504
+ require 'app/app'
505
+
506
+ YARD::Doctest.configure do |doctest|
507
+ doctest.before { @one = true }
508
+ doctest.before('#foo') { @two = true }
509
+ end
510
+ """
511
+ And a file named "app/app.rb" with:
512
+ """
513
+ # @example
514
+ # foo #=> true
515
+ def foo
516
+ @one && @two
517
+ end
518
+ """
519
+ When I run `bundle exec yard doctest`
520
+ Then the output should contain "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips"
521
+
501
522
  Scenario: supports test-name hooks for multiple examples on the same code object
502
523
  Given a file named "doctest_helper.rb" with:
503
524
  """
@@ -29,10 +29,10 @@ module YARD
29
29
  # Append this.name to this.definition if YARD's @example tag is followed by
30
30
  # descriptive text, to support hooks for multiple examples per code object.
31
31
  example_name = if this.name.empty?
32
- this.definition
33
- else
34
- "#{this.definition}@#{this.name}"
35
- end
32
+ this.definition
33
+ else
34
+ "#{this.definition}@#{this.name}"
35
+ end
36
36
 
37
37
  register_hooks(example_name, YARD::Doctest.hooks)
38
38
 
@@ -73,18 +73,12 @@ module YARD
73
73
  exception.set_backtrace backtrace
74
74
  end
75
75
 
76
-
77
-
78
76
  def self.register_hooks(example_name, all_hooks)
79
77
  all_hooks.each do |type, hooks|
80
- hooks.each do |hook|
81
- if hook[:test]
82
- # test-name hooks
83
- send(type, &hook[:block]) if example_name.include?(hook[:test])
84
- else
85
- # global hooks
86
- send(type, &hook[:block])
87
- end
78
+ global_hooks = hooks.select { |hook| !hook[:test] }
79
+ test_hooks = hooks.select { |hook| hook[:test] && example_name.include?(hook[:test]) }
80
+ __send__(type) do
81
+ (global_hooks + test_hooks).each { |hook| instance_exec(&hook[:block]) }
88
82
  end
89
83
  end
90
84
  end
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module Doctest
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
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.6
4
+ version: 0.1.7
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-09-20 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard