spec/csv2hash/definition_spec.rb in csv2hash-0.1.1 vs spec/csv2hash/definition_spec.rb in csv2hash-0.2.0
- old
+ new
@@ -1,13 +1,14 @@
require 'spec_helper'
describe Csv2hash::Definition do
+ let(:valid_rules) { [ { position: [0,0], key: 'name' } ] }
context 'regular context' do
subject do
Csv2hash::Definition.new(
- [ { position: [0,0], key: 'name' } ],
+ valid_rules,
Csv2hash::Definition::MAPPING
)
end
it 'variable should be assigned' do
@@ -32,9 +33,18 @@
subject do
Csv2hash::Definition.new 'rules',Csv2hash::Definition::MAPPING
end
it 'should throw exception' do
expect { subject.validate! }.to raise_error 'rules must be an Array of rules'
+ end
+ end
+
+ context 'structure rules failling validation' do
+ subject do
+ Csv2hash::Definition.new valid_rules, Csv2hash::Definition::MAPPING, { structure_rules: 'invalid structure rule' }
+ end
+ it 'should throw exception' do
+ expect { subject.validate! }.to raise_error 'structure rules must be a Hash of rules'
end
end
end
describe '#default!' do