spec/csv2hash/validator/collection_spec.rb in csv2hash-0.3.0 vs spec/csv2hash/validator/collection_spec.rb in csv2hash-0.4.0
- old
+ new
@@ -8,15 +8,20 @@
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 }
context 'with header' do
let(:options) { { header_size: 1 } }
let(:data_source) { [ [ 'Name' ], [ 'John Doe' ] ]}
it { expect { subject.validate_data! }.to_not raise_error }
@@ -26,11 +31,11 @@
context '#ignore_blank_line' do
let(:data_source) { [ [ ] ] }
before { subject.ignore_blank_line = true }
it { expect { subject.validate_data! }.to_not raise_error }
context 'csv mode' do
- before { subject.exception_mode = false }
+ before { subject.break_on_failure = false }
its(:errors) { should be_empty }
end
end
context 'with invalid data' do
@@ -43,10 +48,14 @@
end
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'}] }