Sha256: ad32cfe9d887c8ca383d16f89ed6255450eb16c2f0b27a619b772d0014c15f87

Contents?: true

Size: 674 Bytes

Versions: 7

Compression:

Stored size: 674 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
auto_increment-1.5.2 spec/lib/incrementor_spec.rb
auto_increment-1.5.1 spec/lib/incrementor_spec.rb
auto_increment-1.5.0 spec/lib/incrementor_spec.rb
auto_increment-1.4.1 spec/lib/incrementor_spec.rb
auto_increment-1.4.0 spec/lib/incrementor_spec.rb
auto_increment-1.3.0 spec/lib/incrementor_spec.rb
auto_increment-1.2.0 spec/lib/incrementor_spec.rb