Sha256: 767a6630f0f5a03b287e60071fb4f2c7f01857ea1c9b46f6a050a335c3c8afee

Contents?: true

Size: 749 Bytes

Versions: 6

Compression:

Stored size: 749 Bytes

Contents

require 'test_helper'

class IndenterTest < ActiveSupport::TestCase

  Indenter = ExpressTemplates::Indenter

  test ".for(:name) takes a block receiving whitespace" 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

  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

6 entries across 6 versions & 1 rubygems

Version Path
express_templates-0.2.7 test/indenter_test.rb
express_templates-0.2.6 test/indenter_test.rb
express_templates-0.2.5 test/indenter_test.rb
express_templates-0.2.4 test/indenter_test.rb
express_templates-0.2.3 test/indenter_test.rb
express_templates-0.2.2 test/indenter_test.rb