spec/csv2hash/validator/mapping_spec.rb in csv2hash-0.3.0 vs spec/csv2hash/validator/mapping_spec.rb in csv2hash-0.4.0
- old
+ new
@@ -8,13 +8,17 @@
definition.default!
end
end
subject do
- Csv2hash::Main.new(definition, data_source, exception_mode=true, ignore_blank_line=false)
+ Csv2hash::Main.new(definition, data_source, ignore_blank_line=false)
end
+ before do
+ allow(subject).to receive(:break_on_failure) { true }
+ end
+
context 'with valid data' do
let(:data_source) { [ [ 'John Doe' ] ]}
it { expect { subject.validate_data! }.to_not raise_error }
end
@@ -23,10 +27,14 @@
it { expect { subject.validate_data! }.to raise_error('undefined name on [0, 0]') }
end
context 'wihtout exception' do
let(:data_source) { [ [ ] ] }
- before { subject.exception_mode = false }
+
+ before do
+ allow(subject).to receive(:break_on_failure) { false }
+ end
+
it { expect(subject.parse.errors.to_csv).to eql ",\"undefined name on [0, 0]\"\n" }
context 'errors should be filled' do
before { subject.parse }
its(:errors) { should eql [{x: 0, y: 0, message: 'undefined name on [0, 0]', key: 'name'}] }