Sha256: 0933f9e2882ad5d7168405e6ca07ea2995598a8711119691dead6327dc222a85

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

require File.expand_path('../../test_helper', File.dirname(__FILE__))

class HelperTest < ActiveSupport::TestCase
  
  def test_initialize_tag
    assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag(
      cms_pages(:default), '{{ cms:helper:method_name }}'
    )
    assert_equal 'method_name', tag.label
    assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag(
      cms_pages(:default), '{{ cms:helper:method-name }}'
    )
    assert_equal 'method-name', tag.label
  end
  
  def test_initialize_tag_with_parameters
    assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag(
      cms_pages(:default), '{{ cms:helper:method_name:param1:param2 }}'
    )
    assert tag.label = 'method_name'
    assert tag.params = 'param1:param2'
  end
  
  def test_initialize_tag_failure
    [
      '{{cms:helper}}',
      '{{cms:not_helper:method_name}}',
      '{not_a_tag}'
    ].each do |tag_signature|
      assert_nil ComfortableMexicanSofa::Tag::Helper.initialize_tag(
        cms_pages(:default), tag_signature
      )
    end
  end
  
  def test_content_and_render
    tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag(
      cms_pages(:default), '{{cms:helper:method_name}}'
    )
    assert_equal "<%= method_name() %>", tag.content
    assert_equal "<%= method_name() %>", tag.render
    
    tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag(
      cms_pages(:default), '{{cms:helper:method_name:param1:param2}}'
    )
    assert_equal "<%= method_name('param1', 'param2') %>", tag.content
    assert_equal "<%= method_name('param1', 'param2') %>", tag.render
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.2.6 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.2.5 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.2.4 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.2.3 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.2.2 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.2.1 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.2.0 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.1.2 test/unit/tags/helper_test.rb
comfortable_mexican_sofa-1.1.1 test/unit/tags/helper_test.rb