spec/csv2hash/structure_validator_spec.rb in csv2hash-0.3.0 vs spec/csv2hash/structure_validator_spec.rb in csv2hash-0.4.0

- old
+ new

@@ -2,25 +2,23 @@ describe Csv2hash::StructureValidator do let(:rules) { [ { position: [0,0], key: 'name' } ] } let(:options) { {} } - let(:exception_mode) { true } let(:definition) do Csv2hash::Definition.new(rules, Csv2hash::Definition::MAPPING, options).tap do |definition| definition.validate! definition.default! end end subject do - Csv2hash::Main.new(definition, data_source, exception_mode, ignore_blank_line=false) + Csv2hash::Main.new(definition, data_source, ignore_blank_line=false) end context 'the csv with errors' do let(:options){ { structure_rules: { 'MaxColumns' => 2 } } } - let(:exception_mode) { false } before { subject.parse } let(:data_source) do [ [ 'John', 'Doe' ], [ 'Jane', 'Doe', 'extra field' ] @@ -35,10 +33,14 @@ context '#MaxColumns' do let(:options){ { structure_rules: { 'MaxColumns' => 2 } } } + before do + allow(subject).to receive(:break_on_failure) { true } + end + context 'valid data' do let(:data_source) do [ [ 'John', 'Doe' ] ] @@ -57,9 +59,13 @@ end end context '#MinColumns' do let(:options){ { structure_rules: { 'MinColumns' => 2 } } } + + before do + allow(subject).to receive(:break_on_failure) { true } + end context 'valid data' do let(:data_source) do [ [ 'John', 'Doe', 'foo' ]