Sha256: 4eb5d27d51236bbbb1b680e0424713b0c5de5358a68d5d1c5d0ca7cf0679243c

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require 'wml_spec_helper'
require 'awesome_print'

describe Weskit::WML::Parser do
  include WMLHelpers

  describe 'parse' do
    specify 'empty lines' do
      Weskit::WML::Parser.string document_with_empty_lines
    end

    context 'attribute' do
      specify 'raw' do
        parsed = Weskit::WML::Parser.string 'a=b'
        parsed[:a].should match_value_of(:b)
      end

      specify 'code' do
        parsed = Weskit::WML::Parser.string ' a= <<b>> '
        parsed[:a].attribute.should be_code
        parsed[:a].should match_value_of(:b)
      end

      specify 'multiline' do
        parsed = Weskit::WML::Parser.string %Q{a= "b \n c"}
        parsed[:a].attribute.should be_multiline
        parsed[:a].should match_value_of("b \n c")
      end

      specify 'escape sequence' do
        parsed = Weskit::WML::Parser.string %Q{ a= "b "" c" }
        parsed[:a].should match_value_of('b " c')
      end

      specify 'translatable' do
        parsed = Weskit::WML::Parser.string ' a= _ "b" '
        parsed[:a].attribute.should be_translatable
        parsed[:a].should match_value_of(:b)
      end
    end

    context 'element' do
      specify 'tags' do
        expect {
          Weskit::WML::Parser.string "[foo]\n[/bar]"
        }.to raise_error Weskit::WML::Errors::ParseError
      end

      specify 'default' do
        parsed = Weskit::WML::Parser.string "[foo]\n[/foo]"
        parsed[0].should have_identifier_of(:foo)
      end

      specify 'amending' do
        parsed = Weskit::WML::Parser.string document_with_amendment
        parsed[0][:bat].should match_value_of(:baz)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weskit-0.1.0 spec/wml/parser_spec.rb