Sha256: a2a0c3643307fac412bcc35e98f1ba440b7d7fc1677ec1fc2f112fcd22585639

Contents?: true

Size: 1.32 KB

Versions: 31

Compression:

Stored size: 1.32 KB

Contents

RSpec.describe Flipper::UI::Decorators::Feature do
  let(:source)  { {} }
  let(:adapter) { Flipper::Adapters::Memory.new(source) }
  let(:flipper) { build_flipper }
  let(:feature) { flipper[:some_awesome_feature] }

  subject do
    described_class.new(feature)
  end

  describe '#initialize' do
    it 'sets the feature' do
      expect(subject.feature).to be(feature)
    end
  end

  describe '#pretty_name' do
    it 'capitalizes each word separated by underscores' do
      expect(subject.pretty_name).to eq('Some Awesome Feature')
    end
  end

  describe '#<=>' do
    let(:on) do
      flipper.enable(:on_a)
      described_class.new(flipper[:on_a])
    end

    let(:on_b) do
      flipper.enable(:on_b)
      described_class.new(flipper[:on_b])
    end

    let(:conditional) do
      flipper.enable_percentage_of_time :conditional_a, 5
      described_class.new(flipper[:conditional_a])
    end

    let(:off) do
      described_class.new(flipper[:off_a])
    end

    it 'sorts :on before :conditional' do
      expect((on <=> conditional)).to be(-1)
    end

    it 'sorts :on before :off' do
      expect((on <=> off)).to be(-1)
    end

    it 'sorts :conditional before :off' do
      expect((conditional <=> off)).to be(-1)
    end

    it 'sorts on key for identical states' do
      expect((on <=> on_b)).to be(-1)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
flipper-ui-1.3.2 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.3.1 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.3.0 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.3.0.pre spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.2.2 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.2.1 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.2.0 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.1.2 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.1.1 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.1.0 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.0.0 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-1.0.0.pre spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.28.3 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.28.2 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.28.1 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.28.0 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.27.1 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.27.0 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.26.2 spec/flipper/ui/decorators/feature_spec.rb
flipper-ui-0.26.0 spec/flipper/ui/decorators/feature_spec.rb