Sha256: bfaec8cc2189223526340fa9c98716b9485cf2db573b8177b6533e7f9c128ff9

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require "assert"
require "undies/source"

class Undies::SourceStack

  class UnitTests < Assert::Context
    desc 'a source stack'
    before do
      @content_file = File.expand_path('test/support/templates/content.html.rb')
      @content_file_source = Undies::Source.new(@content_file)

      @hi_proc = Proc.new do
        _div { _ "Hi!" }
      end
      @hi_proc_source = Undies::Source.new(&@hi_proc)
      @hi_proc_content_file_source = Undies::Source.new({:layout => @content_file}, &@hi_proc)

      @ss = Undies::SourceStack.new(@hi_proc_content_file_source)
    end
    subject { @ss }

    should have_instance_method :pop

    should "be an Array" do
      assert_kind_of Array, subject
    end

    should "base itself on the source" do
      assert_equal @hi_proc_content_file_source, subject.first
      assert_equal @hi_proc_source, Undies::SourceStack.new(@hi_proc_source).first
    end

    should "should stack on the source's layouts" do
      assert_equal @content_file_source, subject.last

      content = Undies::Source.new(@content_file, {
        :layout => (lay1 = Undies::Source.new(@content_file, {
          :layout => (lay2 = Undies::Source.new(@content_file))
        }))
      })

      assert_equal [content, lay1, lay2], Undies::SourceStack.new(content)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
undies-3.1.0 test/unit/source_stack_tests.rb
undies-3.0.0 test/unit/source_stack_tests.rb