File: id_spec.rb

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (38 lines) | stat: -rw-r--r-- 676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
# rubocop:todo all

require 'lite_spec_helper'

describe Mongo::Id do
  it 'starts with ID 1' do
    class IdA
      include Mongo::Id
    end

    expect(IdA.next_id).to eq(1)
  end

  it 'increases each subsequent ID' do
    class IdB
      include Mongo::Id
    end

    expect(IdB.next_id).to eq(1)
    expect(IdB.next_id).to eq(2)
  end

  it 'correctly generates independent IDs for separate classes' do
    class IdC
      include Mongo::Id
    end

    class IdD
      include Mongo::Id
    end

    expect(IdC.next_id).to eq(1)
    expect(IdD.next_id).to eq(1)
    expect(IdC.next_id).to eq(2)
    expect(IdD.next_id).to eq(2)
  end
end