Sha256: 016f63d5299ee0f57cd931d7cfb6ada6a4edbf736be774ed8e837e4fa0040a1f

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Faker::Russian do
  context '#inn' do
    before(:all) do
      DummyModel.reset_callbacks(:validate)
      DummyModel.validates(:field, inn_format: true)
    end

    it 'provide valid inn without arguments' do
      100.times do
        expect(DummyModel.new(field: Faker::Russian.inn)).to be_valid
      end
    end

    it 'provide valid inn with region number' do
      100.times do
        expect(DummyModel.new(field: Faker::Russian.inn(region: 78))).to be_valid
      end
    end

    it 'provide valid inn with kind' do
      100.times do
        expect(DummyModel.new(field: Faker::Russian.inn(kind: [:individual, :legal].sample))).to be_valid
      end
    end

    it 'provide difference inns with sequence' do
      sequenced_inns = 10000.times.map{ |n| Faker::Russian.inn(sequence: n) }
      expect(sequenced_inns.size).to eq(sequenced_inns.uniq.size)
    end

    it 'raise when selecting invalid region' do
      expect{ Faker::Russian.inn(region_number: '90') }.to raise_error
    end

    it 'raise when selecting invalid kind' do
      expect{ Faker::Russian.inn(kind: :shit) }.to raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faker-russian-0.0.1 spec/faker/russian/inn_spec.rb