require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Divisor" do context 'validation' do context 'for ISO 3166' do let(:iso3166) { mock(:validate => true) } before { ISO3166.stub(:new => iso3166) } it 'create a ISO3166 on first call' do ISO3166.should_receive(:new) DivISOr.validate_iso3166('US') end it 'delegates to the ISO3166 class' do iso3166.should_receive(:validate).with('US') DivISOr.validate_iso3166('US') end it 'takes an optional 2nd variable' do iso3166.should_receive(:validate).with('US', :code) DivISOr.validate_iso3166('US', :code) end end context 'for ISO 4217' do let(:iso4217) { mock(:validate => true) } before { ISO4217.stub(:new => iso4217) } it 'create a ISO4217 on first call' do ISO4217.should_receive(:new) DivISOr.validate_iso4217('USD') end it 'delegates to the ISO4217 class' do iso4217.should_receive(:validate).with('USD') DivISOr.validate_iso4217('USD') end it 'takes an optional 2nd variable' do iso4217.should_receive(:validate).with('USD', :code) DivISOr.validate_iso4217('USD', :code) end end context 'for ISO 10383' do let(:iso10383) { mock(:validate => true) } before { ISO10383.stub(:new => iso10383) } it 'create a ISO10383 on first call' do ISO10383.should_receive(:new) DivISOr.validate_iso10383('BARX') end it 'delegates to the ISO10383 class' do iso10383.should_receive(:validate).with('BARX') DivISOr.validate_iso10383('BARX') end it 'takes an optional 2nd variable' do iso10383.should_receive(:validate).with('BARX', :code) DivISOr.validate_iso10383('BARX', :code) end end end end