spec/csv2hash/validator/collection_spec.rb in csv2hash-0.1.1 vs spec/csv2hash/validator/collection_spec.rb in csv2hash-0.2.0
- old
+ new
@@ -1,11 +1,11 @@
require 'spec_helper'
describe Csv2hash::Validator::Collection do
-
+ let(:options) { {} }
let(:definition) do
- Csv2hash::Definition.new([ { position: 0, key: 'name' } ], Csv2hash::Definition::COLLECTION).tap do |definition|
+ Csv2hash::Definition.new([ { position: 0, key: 'name' } ], Csv2hash::Definition::COLLECTION, options).tap do |definition|
definition.validate!
definition.default!
end
end
@@ -15,11 +15,11 @@
context 'with valid data' do
let(:data_source) { [ [ 'John Doe' ] ]}
it { expect { subject.validate_data! }.to_not raise_error }
context 'with header' do
- before { subject.definition.header_size = 1 }
+ let(:options) { { header_size: 1 } }
let(:data_source) { [ [ 'Name' ], [ 'John Doe' ] ]}
it { expect { subject.validate_data! }.to_not raise_error }
end
end
@@ -35,10 +35,10 @@
context 'with invalid data' do
let(:data_source) { [ [ ] ] }
it { expect { subject.validate_data! }.to raise_error('undefined name on [0, 0]') }
context 'with header' do
- before { subject.definition.header_size = 1 }
+ let(:options) { { header_size: 1 } }
let(:data_source) { [ [ 'Name' ], [ ] ]}
it { expect { subject.validate_data! }.to raise_error('undefined name on [1, 0]') }
end
end