Sha256: fb06aa56cf73a6d8ff147668dcfd96c402e55af95da4ed414ef826edb21dc8fd

Contents?: true

Size: 1.19 KB

Versions: 12

Compression:

Stored size: 1.19 KB

Contents

require 'helper'
require 'flipper/types/percentage_of_actors'

RSpec.describe Flipper::Types::Percentage do
  subject {
    described_class.new(5)
  }
  it_should_behave_like 'a percentage'

  describe ".wrap" do
    context "with percentage instance" do
      it "returns percentage instance" do
        expect(described_class.wrap(subject)).to eq(subject)
      end
    end

    context "with Integer" do
      it "returns percentage instance" do
        expect(described_class.wrap(subject.value)).to eq(subject)
      end
    end

    context "with String" do
      it "returns percentage instance" do
        expect(described_class.wrap(subject.value.to_s)).to eq(subject)
      end
    end
  end

  describe "#eql?" do
    it "returns true for same class and value" do
      expect(subject.eql?(described_class.new(subject.value))).to eq(true)
    end

    it "returns false for different value" do
      expect(subject.eql?(described_class.new(subject.value + 1))).to eq(false)
    end

    it "returns false for different class" do
      expect(subject.eql?(Object.new)).to eq(false)
    end

    it "is aliased to ==" do
      expect((subject == described_class.new(subject.value))).to eq(true)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
flipper-0.10.2 spec/flipper/types/percentage_spec.rb
flipper-0.10.1 spec/flipper/types/percentage_spec.rb
flipper-0.10.0 spec/flipper/types/percentage_spec.rb
flipper-0.9.2 spec/flipper/types/percentage_spec.rb
flipper-0.9.1 spec/flipper/types/percentage_spec.rb
flipper-0.9.0 spec/flipper/types/percentage_spec.rb
flipper-0.9.0.beta1 spec/flipper/types/percentage_spec.rb
flipper-0.8.0 spec/flipper/types/percentage_spec.rb
flipper-0.7.5 spec/flipper/types/percentage_spec.rb
flipper-0.7.4 spec/flipper/types/percentage_spec.rb
flipper-0.7.3 spec/flipper/types/percentage_spec.rb
flipper-0.7.2 spec/flipper/types/percentage_spec.rb