spec/document_spec.rb in iniparse-0.2.1 vs spec/document_spec.rb in iniparse-1.0.0
- old
+ new
@@ -1,14 +1,16 @@
require File.dirname(__FILE__) + '/spec_helper'
describe "IniParse::Document" do
- it 'should have a +sections+ reader' do
- IniParse::Document.instance_methods.should include('lines')
+ it 'should have a +lines+ reader' do
+ methods = IniParse::Document.instance_methods.map { |m| m.to_sym }
+ methods.should include(:lines)
end
- it 'should not have a +sections+ writer' do
- IniParse::Document.instance_methods.should_not include('lines=')
+ it 'should not have a +lines+ writer' do
+ methods = IniParse::Document.instance_methods.map { |m| m.to_sym }
+ methods.should_not include(:lines=)
end
it 'should delegate #[] to +lines+' do
doc = IniParse::Document.new
doc.lines.should_receive(:[]).with('key')
@@ -17,9 +19,23 @@
it 'should call #each to +lines+' do
doc = IniParse::Document.new
doc.lines.should_receive(:each)
doc.each { |l| }
+ end
+
+ it 'should be enumerable' do
+ IniParse::Document.included_modules.should include(Enumerable)
+
+ sections = [
+ IniParse::Lines::Section.new('first section'),
+ IniParse::Lines::Section.new('second section')
+ ]
+
+ doc = IniParse::Document.new
+ doc.lines << sections[0] << sections[1]
+
+ doc.map { |line| line }.should == sections
end
describe '#has_section?' do
before(:all) do
@doc = IniParse::Document.new