Sha256: 321b05b835cfa67b41ed73cb5271cca1a6d6d67b139bcf879a286050e1fed8f9

Contents?: true

Size: 770 Bytes

Versions: 4

Compression:

Stored size: 770 Bytes

Contents

require 'spec_helper'

describe CodiceFiscale do
  describe '#calculate' do
    let(:mario_attributes) { {:name => 'mario', :surname => 'rossi', :gender => :male, :birthdate => Date.new(1987, 1, 1),
                              :province_code => 'lc', :city_name => 'Abbadia Lariana'} }

    before do
      subject.config.city_code = nil
      subject.config.country_code = nil
    end

    it 'returns the expected code' do
      subject.calculate(mario_attributes).should == 'RSSMRA87A01A005V'
    end

    context 'when params are not valid' do
      let(:invalid_attributes) { mario_attributes.merge(:name => '') }

      it 'raises an error' do
        lambda { subject.calculate(invalid_attributes) }.should raise_error(ArgumentError)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codice-fiscale-0.0.9 spec/lib/codice_fiscale_spec.rb
codice-fiscale-0.0.8 spec/lib/codice_fiscale_spec.rb
codice-fiscale-0.0.7 spec/lib/codice_fiscale_spec.rb
codice-fiscale-0.0.6 spec/lib/codice_fiscale_spec.rb