Sha256: 5d54b784b06976065edcb95c8fb0e4e01d77a5a6f2c80c3dbec50dfd26a16712

Contents?: true

Size: 1.49 KB

Versions: 13

Compression:

Stored size: 1.49 KB

Contents

require File.join(File.dirname(__FILE__), *%w[.. .. spec_helper])

describe 'LibXML::XML::Node' do
  it 'aliases #name to #element_name' do
    node = LibXML::XML::Node.new 'foo'
    node.must_respond_to :element_name
    node.element_name.must_equal node.name
  end

  it 'aliases #name= to #element_name=' do
    node = LibXML::XML::Node.new 'foo'
    node.must_respond_to :element_name=
    node.element_name.must_equal node.name
    node.element_name = 'bar'
    node.element_name.must_equal 'bar'
  end
end

describe 'LibXML::XML::Attributes' do
  it 'provides a helper to remove a specified attribute' do
    attrs = LibXML::XML::Node.new('foo').attributes
    attrs['foo'] = 'bar'
    attrs['foo'].must_equal 'bar'
    attrs.remove 'foo'
    attrs['foo'].must_be_nil

    attrs['foo'] = 'bar'
    attrs['foo'].must_equal 'bar'
    attrs.remove :foo
    attrs['foo'].must_be_nil
  end

  it 'allows symbols as hash keys' do
    attrs = LibXML::XML::Node.new('foo').attributes
    attrs['foo'] = 'bar'

    attrs['foo'].must_equal 'bar'
    attrs[:foo].must_equal 'bar'
  end

  it 'removes an attribute when set to nil' do
    attrs = LibXML::XML::Node.new('foo').attributes
    attrs['foo'] = 'bar'

    attrs['foo'].must_equal 'bar'
    attrs['foo'] = nil
    attrs['foo'].must_be_nil
  end

  it 'allows attribute values to change' do
    attrs = LibXML::XML::Node.new('foo').attributes
    attrs['foo'] = 'bar'

    attrs['foo'].must_equal 'bar'
    attrs['foo'] = 'baz'
    attrs['foo'].must_equal 'baz'
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sprsquish-blather-0.2.3 spec/blather/core_ext/libxml_spec.rb
sprsquish-blather-0.3.0 spec/blather/core_ext/libxml_spec.rb
sprsquish-blather-0.3.1 spec/blather/core_ext/libxml_spec.rb
sprsquish-blather-0.3.2 spec/blather/core_ext/libxml_spec.rb
sprsquish-blather-0.3.3 spec/blather/core_ext/libxml_spec.rb
sprsquish-blather-0.3.4 spec/blather/core_ext/libxml_spec.rb
blather-0.2.2 spec/blather/core_ext/libxml_spec.rb
blather-0.3.1 spec/blather/core_ext/libxml_spec.rb
blather-0.3.0 spec/blather/core_ext/libxml_spec.rb
blather-0.2.3 spec/blather/core_ext/libxml_spec.rb
blather-0.3.4 spec/blather/core_ext/libxml_spec.rb
blather-0.3.3 spec/blather/core_ext/libxml_spec.rb
blather-0.3.2 spec/blather/core_ext/libxml_spec.rb