Sha256: b3a2e65766d8b48d21e55c6994143631cc651764f292f06cdcaaad1cf5f95478

Contents?: true

Size: 1.67 KB

Versions: 109

Compression:

Stored size: 1.67 KB

Contents

require 'helper'

class TestSlimLogicLess < TestSlim
  def setup
    Slim::Sections.set_default_options(:dictionary_access => :symbol)
  end

  def teardown
    Slim::Sections.set_default_options(:dictionary => 'self')
  end

  def test_sections
    source = %q{
p
 - person
  .name = name
}

    hash = {
      :person => [
        { :name => 'Joe', },
        { :name => 'Jack', }
      ]
    }

    assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, :scope => hash, :sections => true
  end

  def test_sections_string_access
    source = %q{
p
 - person
  .name = name
}

    hash = {
      'person' => [
        { 'name' => 'Joe', },
        { 'name' => 'Jack', }
      ]
    }

    assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, :scope => hash, :sections => true, :dictionary_access => :string
  end

  def test_flag_section
    source = %q{
p
 - show_person
   - person
    .name = name
 - show_person
   | shown
}

    hash = {
      :show_person => true,
      :person => [
        { :name => 'Joe', },
        { :name => 'Jack', }
      ]
    }

    assert_html '<p><div class="name">Joe</div><div class="name">Jack</div>shown</p>', source, :scope => hash, :sections => true
  end

  def test_inverted_section
    source = %q{
p
 - person
  .name = name
 -! person
  | No person
 - !person
  |  No person 2
}

    hash = {}

    assert_html '<p>No person No person 2</p>', source, :scope => hash, :sections => true
  end

  def test_output_with_content
    source = %{
p = method_with_block do
  block
}
    assert_runtime_error 'Output statements with content are forbidden in sections mode', source, :sections => true
  end
end

Version data entries

109 entries across 64 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.7.5 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.7.4 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.7.4 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.7.3 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.7.3 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.7.2 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.7.2 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.7.1 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.7.1 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.7.0 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.7.0 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.6.9 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.6.9 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.6.8 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.6.8 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.6.7 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.6.7 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb
classiccms-0.6.6 vendor/bundle/gems/slim-1.2.0/test/slim/test_sections.rb
classiccms-0.6.6 vendor/bundle/gems/slim-1.2.1/test/slim/test_sections.rb