root/specs/fastxml_node_attribute_spec.rb

Revision 2168c40635a237e84a69b74bb34c24f230052ae9, 1.3 KB (checked in by Mark Guzman <segfault@…>, 4 months ago)

finally loading properly as a gem

  • Property mode set to 100644
Line 
1# encoding: utf-8 # :nodoc:
2%w[ ../ext ./ext ../lib ./lib ].each { |lp| $: << lp }
3require 'fastxml'
4
5describe FastXml::AttrList, ' functionality' do
6  before(:all) do
7    data_raw = open( "./test_data/hasno_feed.xml" )
8    @data_ary = data_raw.readlines
9    data_raw.close
10    @data_str = @data_ary.join('')
11    @doc = FastXml::Doc.new( @data_str )
12    @node = @doc.root
13  end
14 
15  it 'should provide an indexer [] method using both symbols and strings' do
16    @node.should respond_to( 'attr' )
17    @node.attr.should respond_to( '[]' )
18    @node.attr[:ab].should be_nil
19    @node.attr["ab"].should be_nil
20  end
21 
22  it 'should provide an indexer p[] mutator method using both symbols and strings' do
23    @node.should respond_to( 'attr' )
24    @node.attr.should respond_to( '[]' )
25    @node.attr[:ab] = "test"
26    @node.attr[:ab].should == "test"
27    @node.attr["ab"].should == "test"
28  end
29 
30  it 'should provide an include? method' do
31    @node.should respond_to( 'attr' )
32    @node.attr.should respond_to( 'include?' )
33    @node.attr.include?(:ab).should == true
34  end
35
36  it "should remove an attribute when it's value is set to nil" do
37    @node.should respond_to( 'attr' )
38    @node.attr.should respond_to( '[]' )
39    @node.attr[:ab].should == "test"
40    @node.attr[:ab] = nil
41    @node.attr[:ab].should == nil
42    @node.attr.include?(:ab).should == nil   
43  end
44end
Note: See TracBrowser for help on using the browser.