Set version attributes before evaluating block

Ref #25.
This commit is contained in:
Thibaut Courouble 2016-01-24 15:38:54 -05:00
parent 357418d4a3
commit c3b9502657
2 changed files with 3 additions and 2 deletions

View file

@ -16,11 +16,11 @@ module Docs
return @version unless block_given? return @version unless block_given?
klass = Class.new(self) klass = Class.new(self)
klass.class_exec(&block)
klass.name = name klass.name = name
klass.slug = slug klass.slug = slug
klass.version = version klass.version = version
klass.links = links klass.links = links
klass.class_exec(&block)
@versions ||= [] @versions ||= []
@versions << klass @versions << klass
klass klass

View file

@ -338,7 +338,7 @@ class DocsDocTest < MiniTest::Spec
context "with args" do context "with args" do
it "creates a version subclass" 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 assert_equal [version], doc.versions
@ -351,6 +351,7 @@ class DocsDocTest < MiniTest::Spec
assert_equal '8', version.release assert_equal '8', version.release
assert_equal 'name', version.name assert_equal 'name', version.name
assert_equal 'type', version.type assert_equal 'type', version.type
assert_equal ['https://4'], version.links
end end
end end
end end