Sha256: 0f63207fe0d75a03e301a906f2683702ec7cb98ccd71031eafeb492c57a86698

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe "Templates::Tags" do
  dataset :pages
  before :each do
    @page = pages(:home)
    @page.parts.build(:name => "False", :content => 'false')
    @page.parts.build(:name => "True", :content => 'true')
  end
  
  describe "<r:boolean_part>" do
    it "should expand its contents" do
      @page.should render('<r:boolean_part>true</r:boolean_part>').as('true')
    end
  end
  
  describe "<r:boolean_part:if>" do
    it "should expand its contents if the selected part evaluates to true" do
      @page.should render('<r:boolean_part:if part="True">yes!</r:boolean_part:if>').as('yes!')
    end
    
    it "should not expand its contents if the selected part does not evaluate to true" do
      @page.should render('<r:boolean_part:if part="False">yes!</r:boolean_part:if>').as('')
    end
    
    it "should raise an error if the part attribute is missing" do
      @page.should render('<r:boolean_part:if>yes!</r:boolean_part:if>').with_error("`boolean_part:if' tag requires a 'part' attribute")
    end
  end
  
  describe "<r:boolean_part:unless>" do
    it "should not expand its contents if the selected part evaluates to true" do
      @page.should render('<r:boolean_part:unless part="True">yes!</r:boolean_part:unless>').as('')
    end
    
    it "should expand its contents if the selected part does not evaluate to true" do
      @page.should render('<r:boolean_part:unless part="False">yes!</r:boolean_part:unless>').as('yes!')
    end
    
    it "should raise an error if the part attribute is missing" do
      @page.should render('<r:boolean_part:unless>yes!</r:boolean_part:unless>').with_error("`boolean_part:unless' tag requires a 'part' attribute")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
radiant-templates-extension-1.0.6 spec/models/tags_spec.rb
radiant-templates-extension-1.0.5 spec/models/tags_spec.rb
radiant-templates-extension-1.0.4 spec/models/tags_spec.rb
radiant-templates-extension-1.0.3 spec/models/tags_spec.rb
radiant-templates-extension-1.0.2 spec/models/tags_spec.rb
radiant-templates-extension-1.0.1 spec/models/tags_spec.rb
radiant-templates-extension-1.0.0 spec/models/tags_spec.rb