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_admin-1.6.4 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.11.2 test/indenter_test.rb
express_admin-1.6.3 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.11.1 test/indenter_test.rb
express_admin-1.6.2 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.6.1 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.11.0 test/indenter_test.rb
express_admin-1.6.0 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.10.1 test/indenter_test.rb
express_admin-1.5.0 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.4.11 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.4.10 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.4.9 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.8 test/indenter_test.rb
express_admin-1.4.8 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.7 test/indenter_test.rb
express_admin-1.4.7 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.6 test/indenter_test.rb
express_admin-1.4.6 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.5 test/indenter_test.rb