Browse Source

Set version attributes before evaluating block

Ref #25.
Thibaut Courouble 10 years ago
parent
commit
c3b9502657
2 changed files with 3 additions and 2 deletions
  1. 1 1
      lib/docs/core/doc.rb
  2. 2 1
      test/lib/docs/core/doc_test.rb

+ 1 - 1
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

+ 2 - 1
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