Sha256: 45129d1e5b3c400b169aff66a7df7c9e78be1c67d14ec1475cf7126a579f80b2

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require 'test_helper'

class ZafuRubyLessTest < Test::Unit::TestCase
  include RubyLess
  def self.process_unknown(callback); end;
  include Zafu::Security
  include Zafu::Process::RubyLessProcessing
  def helper; self.class; end
  safe_method :one => {:class => String, :method => "main_one"}


  context 'With a Markup' do
    setup do
      @markup = Zafu::Markup.new('p')
    end

    context 'parsing an attribute without dynamic strings' do
      should 'not alter string' do
        set_markup_attr(@markup, :name, 'this is a string')
        assert_equal '<p name=\'this is a string\'>foo</p>', @markup.wrap('foo')
      end
    end

    context 'parsing an attribute with dynamic content' do
      should 'use RubyLess to translate content' do
        set_markup_attr(@markup, :name, 'this #{one}')
        assert_equal '<p name=\'<%= "this #{main_one}" %>\'>foo</p>', @markup.wrap('foo')
      end

      context 'with ruby errors' do
        should 'raise a RubyLess::SyntaxError' do
          assert_raises(RubyLess::SyntaxError) do
            set_markup_attr(@markup, :name, 'this #{one}}')
          end
        end

        should 'produce an error message with the original attribute' do
          begin
            set_markup_attr(@markup, :name, 'this #{one}}')
          rescue RubyLess::Error => err
            assert_match %r{parse error on value "\}" \(tRCURLY\)}, err.message
          end
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zafu-0.7.8 test/ruby_less_test.rb
zafu-0.7.7 test/ruby_less_test.rb
zafu-0.7.6 test/ruby_less_test.rb
zafu-0.7.5 test/ruby_less_test.rb