Sha256: c66e7afebfe1eb09f55bcf179f968d7610cbe3aaa9735cda1d04b6ca831fd9a4

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'lib', 'tadpole')

describe Tadpole::LocalTemplate do
  before do
    Tadpole.template_paths.clear
    Tadpole.register_template_path(File.dirname(__FILE__) + '/examples')
  end
  
  describe '.inherits' do
    it "should inherit from a relative path" do
      Tadpole('inherits/inherits_b').run.should == "abc"
    end
    
    it "should automatically inherit parent directories" do
      Tadpole('inherits/inherits_b/inherits_c').run.should == "abcd"
    end
    
    it "should inherit absolute paths from top of registered template paths" do
      Tadpole('inherits/inherits_d').run.should == "ab"
    end
    
    it "should order template_paths properly" do
      paths = Tadpole('inherits/inherits_b/inherits_c').template_paths
      paths.map! {|p| p.gsub(Tadpole.template_paths.first + '/', '') }
      paths.should == ["inherits/inherits_b/inherits_c", "inherits/inherits_b", "inherits/inherits_a", "inherits"]
    end
    
    it "should accept multiple inheritances" do
      paths = Tadpole('inherits/inherits_e').template_paths
      paths.map! {|p| p.gsub(Tadpole.template_paths.first + '/', '') }
      paths.should == ["inherits/inherits_e", "inherits/inherits_b", "inherits/inherits_a", "inherits"]
    end
  end
  
  describe '.T' do
    it "should refer to a template" do
      Tadpole('T').run.should == 'info'
    end
    
    it "should refer to the same template path even in a subclass" do
      Tadpole('T/derived').run.should == 'info'
    end
    
    it "should refer to the subclassed path if the section exists in the subclass" do
      Tadpole('T/derived2').run.should == 'notinfo'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tadpole-0.1.7 spec/local_template_spec.rb
tadpole-0.1.4 spec/local_template_spec.rb
tadpole-0.1.5 spec/local_template_spec.rb
tadpole-0.1.6 spec/local_template_spec.rb