spec/fbo/parser_spec.rb in fbo-0.1.4 vs spec/fbo/parser_spec.rb in fbo-0.1.5
- old
+ new
@@ -5,11 +5,11 @@
let(:contents) { "<PRESOL>\n</PRESOL>\n<COMBINE>\n</COMBINE>\n<AMDCSS>\n</AMDCSS>\n" }
let(:file) { stub('FBO::File', contents: contents) }
subject { FBO::Parser.new(file) }
it 'parses the data all at once' do
- subject.expects(:parse_string).with(file.contents)
+ subject.expects(:parse_string).with(file.contents)
subject.parse
end
it 'returns a tree representing all notices' do
tree = subject.parse
@@ -45,8 +45,28 @@
notice_types = tree.elements.map { |e| e.class.name }.sort
notice_types.must_equal [ 'FBO::Dump::AmendmentNode',
'FBO::Dump::CombinedSolicitationNode',
'FBO::Dump::PresolicitationNode' ]
+ end
+ end
+
+ context 'a bad String' do
+ let(:contents) { "<PRESOL>\n</PRESOL>\n<COMBINE>\n<COMBINE>\n</COMBINE>\n<AMDCSS>\n</AMDCSS>\n" }
+ let(:file) { stub('FBO::File', contents: contents) }
+ subject { FBO::Parser.new(file) }
+
+ it 'raises a ParserError' do
+ proc { subject.parse }.must_raise FBO::ParserError
+ end
+ end
+
+ context 'a collection of data with a bad String' do
+ let(:contents) { [ '<PRESOL></PRESOL>', '<COMBINE><COMBINE></COMBINE>', '<AMDCSS></AMDCSS>' ] }
+ let(:file) { stub('FBO::ChunkedFile', contents: contents) }
+ subject { FBO::Parser.new(file) }
+
+ it 'raises a ParserError' do
+ proc { subject.parse }.must_raise FBO::ParserError
end
end
end