root/specs/fastxml_nodelist_spec.rb

Revision 2168c40635a237e84a69b74bb34c24f230052ae9, 1.6 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
2%w[ ../ext ./ext ../lib ./lib ].each { |lp| $: << lp }
3
4require 'fastxml'
5
6describe FastXml::NodeList, ' functionality' do
7  before(:all) do
8    data_raw = open( "./test_data/hasno_feed.xml" )
9    @data_ary = data_raw.readlines
10    data_raw.close
11    @data_str = @data_ary.join('')
12    @doc = FastXml::Doc.new( @data_str )
13    @list = @doc.children
14  end
15 
16  it 'should provide a length method' do
17    @list.length.should_not be_nil
18    @list.length.should >= 1
19  end
20 
21  it 'should have an index accessor' do
22    @list[0].should_not be_nil
23  end
24 
25  it 'should have an entry method ala Array' do
26    @list.entry(0).should_not be_nil
27    @list.entry(0).should == @list[0]
28  end
29 
30  it 'entry should not explode when faced with insane indexes' do
31    @list.entry(99999999**99999).should be_nil
32    @list.entry(0x3fffffff).should be_nil
33  end
34 
35  it 'should provide an each method' do
36    @list.should respond_to(:each)
37    cnt = 0
38    @list.each do |x|
39      x.should_not be_nil
40      cnt += 1
41    end
42    @list.length.should == cnt
43  end
44 
45  it 'should provide an inspect method' do
46    @list.should respond_to( :inspect )
47    @list.inspect.should_not be_nil
48  end
49 
50  it 'should provide a first method' do
51    @list.should respond_to( :first )
52    @list.first.should_not be_nil
53    @list.first.should == @list[0]
54    @list.first.to_s.should == @list[0].to_s
55  end
56 
57  it 'should provide a last method' do
58    @list.should respond_to( :last )
59    @list.last.should_not be_nil
60    @list.last.should == @list[-1]
61    @list.last.to_s.should == @list[-1].to_s
62  end
63
64end
Note: See TracBrowser for help on using the browser.