Sha256: 0afc789b4dd4040c3ddacd0007753d9c3052274ad47f359ad32f87d485c10b39

Contents?: true

Size: 783 Bytes

Versions: 68

Compression:

Stored size: 783 Bytes

Contents

require 'test_helper'

class IndenterTest < ActiveSupport::TestCase

  Indenter = ExpressTemplates::Indenter

  test ".for(:name) takes a block receiving whitespace" do
    Indenter.for(:foo) do
      assert_equal "\n  ", Indenter.for(:foo) { |indent, indent_with_newline| indent_with_newline }
      assert_equal "  ", Indenter.for(:foo) { |indent, indent_with_newline| indent }
    end
  end

  test "nesting blocks increases whitespace accordingly" do
    nested_whitespace = Indenter.for(:foo) do |ws1|
      Indenter.for(:foo) do |ws2|
        ws2
      end
    end
    assert_equal "  ", nested_whitespace
  end

  test ".for(:name) returns current indent without newline when block is not given" do
    assert_equal "", Indenter.for(:foo) { |_| Indenter.for(:foo) }
  end

end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
express_templates-0.4.1 test/indenter_test.rb
express_templates-0.4.0 test/indenter_test.rb
express_templates-0.3.6 test/indenter_test.rb
express_templates-0.3.5 test/indenter_test.rb
express_templates-0.3.4 test/indenter_test.rb
express_templates-0.3.2 test/indenter_test.rb
express_templates-0.3.1 test/indenter_test.rb
express_templates-0.3.0 test/indenter_test.rb