Sha256: b758dc2e8065d6042402b65952c76b1eb762c48e3e60a1328c409ca2ab3be762

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

require '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

2 entries across 2 versions & 1 rubygems

Version Path
radiant-templates-extension-1.0.8 spec/models/tags_spec.rb
radiant-templates-extension-1.0.7 spec/models/tags_spec.rb