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
|