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.4.5 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.4 test/indenter_test.rb
express_templates-0.9.3 test/indenter_test.rb
express_admin-1.4.4 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.4.3 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.1 test/indenter_test.rb
express_admin-1.4.2 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.9.0 test/indenter_test.rb
express_admin-1.4.1 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.4.0 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.8.0 test/indenter_test.rb
express_admin-1.3.2 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.3.1 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.7.1 test/indenter_test.rb
express_templates-0.7.0 test/indenter_test.rb
express_admin-1.3.0 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.2.1 vendor/gems/express_templates/test/indenter_test.rb
express_admin-1.2.0 vendor/gems/express_templates/test/indenter_test.rb
express_templates-0.5.0 test/indenter_test.rb
express_templates-0.4.2 test/indenter_test.rb