Sha256: e436d75437e09ff140ef9120a381114f8f451f8c1e916d24c16e1deb5366ed38

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require "assert"

require "undies/source_stack"

class Undies::SourceStack

  class BasicTests < Assert::Context
    desc 'a source stack'
    before do
      @content_file = File.expand_path('test/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

4 entries across 4 versions & 1 rubygems

Version Path
undies-2.2.1 test/source_stack_test.rb
undies-2.2.0 test/source_stack_test.rb
undies-2.1.0 test/source_stack_test.rb
undies-2.0.0 test/source_stack_test.rb