Sha256: 8312154f067e2dd7c942f8ec04de55a51fa46babe6a9d41a21031725003e33b5

Contents?: true

Size: 1.72 KB

Versions: 29

Compression:

Stored size: 1.72 KB

Contents

RSpec.describe Flipper::Actor do
  it 'initializes with and knows flipper_id' do
    actor = described_class.new("User;235")
    expect(actor.flipper_id).to eq("User;235")
  end

  describe '#eql?' do
    it 'returns true if same class and flipper_id' do
      actor1 = described_class.new("User;235")
      actor2 = described_class.new("User;235")
      expect(actor1.eql?(actor2)).to be(true)
    end

    it 'returns false if same class but different flipper_id' do
      actor1 = described_class.new("User;235")
      actor2 = described_class.new("User;1")
      expect(actor1.eql?(actor2)).to be(false)
    end

    it 'returns false for different class' do
      actor1 = described_class.new("User;235")
      actor2 = Struct.new(:flipper_id).new("User;235")
      expect(actor1.eql?(actor2)).to be(false)
    end
  end

  describe '#==' do
    it 'returns true if same class and flipper_id' do
      actor1 = described_class.new("User;235")
      actor2 = described_class.new("User;235")
      expect(actor1.==(actor2)).to be(true)
    end

    it 'returns false if same class but different flipper_id' do
      actor1 = described_class.new("User;235")
      actor2 = described_class.new("User;1")
      expect(actor1.==(actor2)).to be(false)
    end

    it 'returns false for different class' do
      actor1 = described_class.new("User;235")
      actor2 = Struct.new(:flipper_id).new("User;235")
      expect(actor1.==(actor2)).to be(false)
    end
  end

  describe '#hash' do
    it 'returns a hash-value based on the flipper id' do
      h = {
        described_class.new("User;123") => true
      }
      expect(h).to have_key(described_class.new("User;123"))
      expect(h).not_to have_key(described_class.new("User;456"))
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
flipper-0.26.0 spec/flipper/actor_spec.rb
flipper-0.26.0.rc2 spec/flipper/actor_spec.rb
flipper-0.26.0.rc1 spec/flipper/actor_spec.rb
flipper-0.25.4 spec/flipper/actor_spec.rb
flipper-0.25.3 spec/flipper/actor_spec.rb
flipper-0.25.2 spec/flipper/actor_spec.rb
flipper-0.25.1 spec/flipper/actor_spec.rb
flipper-0.25.0 spec/flipper/actor_spec.rb
flipper-0.24.1 spec/flipper/actor_spec.rb