Sha256: 0b4c493398b7311df3084c457c4d171c5a93579491714a8ea8a1c769944d67c0

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

require 'wml_spec_helper'

describe Weskit::WML::Builder do
  include WMLHelpers

  let(:element) { Weskit::WML::Element.new :foo }

  specify 'builds attributes' do
    reference = Weskit::WML::Element.new(:foo)                 \
      << Weskit::WML::Attribute.new(:bar, :foo)                \
      << Weskit::WML::Attribute.new(:baz, :foo, :code => true) \
      << Weskit::WML::Attribute.new(:bat, :foo, :translatable => true)

    element.build do
      bar :foo
      baz :foo, :code => true
      bat :foo, :translatable => true
    end

    element.should have_same_representation_as(reference)
  end

  specify 'builds elements' do
    reference = Weskit::WML::Element.new(:foo) \
      << Weskit::WML::Element.new(:baz)        \
      << Weskit::WML::Element.new(:bar)        \
      << sample_amendment

    element.build do
      baz {}
      bar {}
      bar :amendment => true do
        bat :baz
      end
    end

    element.should have_same_representation_as(reference)
  end

  specify 'convert hashes' do
    hash = {
      :a => :foo,
      :b => {
        :c => :bar
      }
    }

    converted = Weskit::WML::Builder.convert hash
    converted[:a].should match_value_of(:foo)
    converted.elements[:c].should match_value_of(:bar)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
weskit-0.3.6 spec/wml/builder_spec.rb
weskit-0.3.5 spec/wml/builder_spec.rb
weskit-0.3.4 spec/wml/builder_spec.rb
weskit-0.3.3 spec/wml/builder_spec.rb
weskit-0.3.2 spec/wml/builder_spec.rb
weskit-0.3.1 spec/wml/builder_spec.rb
weskit-0.3.0 spec/wml/builder_spec.rb
weskit-0.2.1 spec/wml/builder_spec.rb
weskit-0.2.0 spec/wml/builder_spec.rb
weskit-0.1.0 spec/wml/builder_spec.rb