spec/csv2hash/validator/mapping_spec.rb in csv2hash-0.2.1 vs spec/csv2hash/validator/mapping_spec.rb in csv2hash-0.3.0
- old
+ new
@@ -8,11 +8,11 @@
definition.default!
end
end
subject do
- Csv2hash.new(definition, 'file_path', true, data_source)
+ Csv2hash::Main.new(definition, data_source, exception_mode=true, ignore_blank_line=false)
end
context 'with valid data' do
let(:data_source) { [ [ 'John Doe' ] ]}
it { expect { subject.validate_data! }.to_not raise_error }
@@ -24,11 +24,11 @@
end
context 'wihtout exception' do
let(:data_source) { [ [ ] ] }
before { subject.exception_mode = false }
- it { subject.parse.errors.to_csv.should eql ",\"undefined name on [0, 0]\"\n" }
+ 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'}] }
end
@@ -46,11 +46,11 @@
{ position: [1,0], key: 'agree', values: ['yes', 'no'] },
{ position: [2,0], key: 'agree', values: ['yes', 'no'] }
]
end
let(:data_source) { [ [ 'what?' ], [ 'yes', 'what?' ], [ 'yes', 'what?', 'no' ] ] }
- it { subject.parse.errors.to_csv.should eql(
+ it { expect(subject.parse.errors.to_csv).to eql(
"what?,\"agree not supported, please use one of [\"\"yes\"\", \"\"no\"\"]\"\n") }
end
context 'range values' do
let(:rules) do
[
@@ -58,11 +58,11 @@
{ position: [1,0], key: 'score', values: 1..10 },
{ position: [2,0], key: 'score', values: 1..10 }
]
end
let(:data_source) { [ [ 12 ], [ 2, 12 ], [ 3, 12, 1 ] ] }
- it { subject.parse.errors.to_csv.should eql("12,\"score not supported, please use one of 1..10\"\n") }
+ it { expect(subject.parse.errors.to_csv).to eql("12,\"score not supported, please use one of 1..10\"\n") }
end
end
context 'with extra_validator' do
let(:definition) do
@@ -91,6 +91,5 @@
class DowncaseValidator < Csv2hash::ExtraValidator
def valid? rule, value
!!(value.match /^[a-z]+$/)
end
end
-