Sha256: c4cadcd23df9830d9dcbc7fb105e801cd2b60e7f40312ddd00db9ce48e4fb060

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe AutoIncrement::Incrementor do
  {
    nil => 1,
    0 => 1,
    1 => 2,
    'A' => 'B',
    'Z' => 'AA',
    'AA' => 'AB',
    'AAAAA' => 'AAAAB'
  }.each do |previous_value, next_value|
    describe "increment value for #{previous_value}" do
      it do
        allow(subject).to receive(:maximum) { previous_value }
        expect(subject.send(:increment)).to eq next_value
      end
    end
  end

  describe 'initial value of string' do
    subject do
      AutoIncrement::Incrementor.new initial: 'A'
    end

    it do
      allow(subject).to receive(:maximum) { nil }
      expect(subject.send(:increment)).to eq 'A'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_increment-1.6.1 spec/lib/incrementor_spec.rb