Sha256: 56800f231b6350167401c917a75ead48720fae50d91c7b5c36eb38c3c49c9663

Contents?: true

Size: 1.55 KB

Versions: 18

Compression:

Stored size: 1.55 KB

Contents

require 'test_helper'

class RegexpTest < Test::Unit::TestCase
  include Liquid

  def test_empty
    assert_equal [], ''.scan(QuotedFragment)
  end

  def test_quote
    assert_equal ['"arg 1"'], '"arg 1"'.scan(QuotedFragment)
  end

  def test_words
    assert_equal ['arg1', 'arg2'], 'arg1 arg2'.scan(QuotedFragment)
  end

  def test_tags
    assert_equal ['<tr>', '</tr>'], '<tr> </tr>'.scan(QuotedFragment)
    assert_equal ['<tr></tr>'], '<tr></tr>'.scan(QuotedFragment)
    assert_equal ['<style', 'class="hello">', '</style>'], %|<style class="hello">' </style>|.scan(QuotedFragment)
  end

  def test_quoted_words
    assert_equal ['arg1', 'arg2', '"arg 3"'], 'arg1 arg2 "arg 3"'.scan(QuotedFragment)
  end

  def test_quoted_words
    assert_equal ['arg1', 'arg2', "'arg 3'"], 'arg1 arg2 \'arg 3\''.scan(QuotedFragment)
  end

  def test_quoted_words_in_the_middle
    assert_equal ['arg1', 'arg2', '"arg 3"', 'arg4'], 'arg1 arg2 "arg 3" arg4   '.scan(QuotedFragment)
  end

  def test_variable_parser
    assert_equal ['var'],                               'var'.scan(VariableParser)
    assert_equal ['var', 'method'],                     'var.method'.scan(VariableParser)
    assert_equal ['var', '[method]'],                   'var[method]'.scan(VariableParser)
    assert_equal ['var', '[method]', '[0]'],            'var[method][0]'.scan(VariableParser)
    assert_equal ['var', '["method"]', '[0]'],          'var["method"][0]'.scan(VariableParser)
    assert_equal ['var', '[method]', '[0]', 'method'],  'var[method][0].method'.scan(VariableParser)
  end
end # RegexpTest

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
liquid-2.6.3 test/liquid/regexp_test.rb
liquid-2.6.2 test/liquid/regexp_test.rb
liquid-2.6.1 test/liquid/regexp_test.rb
liquid-2.5.5 test/liquid/regexp_test.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/liquid-2.6.0/test/liquid/regexp_test.rb
liquid-2.6.0 test/liquid/regexp_test.rb
liquid-2.5.4 test/liquid/regexp_test.rb
liquid-2.6.0.rc1 test/liquid/regexp_test.rb
liquid-2.5.3 test/liquid/regexp_test.rb
liquid-2.5.1 test/liquid/regexp_test.rb
wordify_liquid-2.5.1 test/liquid/regexp_test.rb
liquid-2.5.0 test/liquid/regexp_test.rb
liquid-2.4.1 test/liquid/regexp_test.rb
liquid-2.4.0 test/liquid/regexp_test.rb
spinto-liquid-2.3.0.3 test/liquid/regexp_test.rb
spinto-liquid-2.3.0.2 test/liquid/regexp_test.rb
spinto-liquid-2.3.0.1 test/liquid/regexp_test.rb
liquid-2.3.0 test/liquid/regexp_test.rb