File: gate_spec.rb

package info (click to toggle)
ruby-flipper 0.26.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,296 kB
  • sloc: ruby: 16,377; sh: 61; javascript: 24; makefile: 14
file content (45 lines) | stat: -rw-r--r-- 945 bytes parent folder | download | duplicates (3)
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
39
40
41
42
43
44
45
require 'flipper/ui/decorators/gate'

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

  subject do
    described_class.new(gate, false)
  end

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

    it 'sets value' do
      expect(subject.value).to eq(false)
    end
  end

  describe '#as_json' do
    before do
      @result = subject.as_json
    end

    it 'returns Hash' do
      expect(@result).to be_instance_of(Hash)
    end

    it 'includes key' do
      expect(@result['key']).to eq('boolean')
    end

    it 'includes pretty name' do
      expect(@result['name']).to eq('boolean')
    end

    it 'includes value' do
      expect(@result['value']).to be(false)
    end
  end
end