Sha256: 9386797c1e9562e465a28203e3d7729bf6ffc4ac4aab82705ba3f49d3d04501c

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ISO4217 do

  let(:data) { {:code => "AFN", :numeric_code => "971", :country => "AFGHANISTAN", :currency => "Afghani"} }
  let(:different_data) {{:some => 'data'}}
  let(:iso_4217) { ISO4217.new(data) }

  it 'is equal to another ISO4217 object if contains the same data' do
    same_iso_4217 = ISO4217.new(data)
    different_iso_4217 = ISO4217.new(different_data)
    iso_4217.should == same_iso_4217
    iso_4217.should_not == different_iso_4217
  end

  it 'responds to code' do
    iso_4217.code.should == 'AFN'
  end

  it 'responds to numeric_code' do
    iso_4217.numeric_code.should == '971'
  end

  it 'responds to country' do
    iso_4217.country.should == 'AFGHANISTAN'
  end

  it 'responds to currency' do
    iso_4217.currency.should == 'Afghani'
  end
end

describe ISO4217::Codes do
  context 'for simple data' do
    let(:all_records) { [mock, mock] }
    let(:iso_records) { mock(:all => all_records) }
    before { ISORecords.stub(:new => iso_records) }

    it 'gets all matching iso_record' do
      iso_records.should_receive(:all).with('USD', :code)
      ISO4217::Codes.new.all('USD') {|a| a == a }
    end

    it 'builds objects from each record' do
      all_records.each do |record|
        ISO4217.should_receive(:new).with(record)
      end
      ISO4217::Codes.new.all('USD') {|a| ISO4217.new(a) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
divISOr-1.0.7 spec/divISOr/iso4217_spec.rb
divISOr-1.0.4 spec/divISOr/iso4217_spec.rb
divISOr-1.0.3 spec/divISOr/iso4217_spec.rb
divISOr-1.0.2 spec/divISOr/iso4217_spec.rb
divISOr-1.0.1 spec/divISOr/iso4217_spec.rb
divISOr-1.0.0 spec/divISOr/iso4217_spec.rb