From c3b950265797800ede1a7b4f27073aab6b34b18d Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 24 Jan 2016 15:38:54 -0500 Subject: [PATCH] Set version attributes before evaluating block Ref #25. --- lib/docs/core/doc.rb | 2 +- test/lib/docs/core/doc_test.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index 52bb3a33..f84908b9 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -16,11 +16,11 @@ module Docs return @version unless block_given? klass = Class.new(self) - klass.class_exec(&block) klass.name = name klass.slug = slug klass.version = version klass.links = links + klass.class_exec(&block) @versions ||= [] @versions << klass klass diff --git a/test/lib/docs/core/doc_test.rb b/test/lib/docs/core/doc_test.rb index e836d42c..2316ce8e 100644 --- a/test/lib/docs/core/doc_test.rb +++ b/test/lib/docs/core/doc_test.rb @@ -338,7 +338,7 @@ class DocsDocTest < MiniTest::Spec context "with args" do it "creates a version subclass" do - version = doc.version('4') { self.release = '8'} + version = doc.version('4') { self.release = '8'; self.links = ["https://#{self.version}"] } assert_equal [version], doc.versions @@ -351,6 +351,7 @@ class DocsDocTest < MiniTest::Spec assert_equal '8', version.release assert_equal 'name', version.name assert_equal 'type', version.type + assert_equal ['https://4'], version.links end end end