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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
RSpec.describe Flipper::Gates::Boolean do
let(:feature_name) { :search }
subject do
described_class.new
end
def context(bool)
Flipper::FeatureCheckContext.new(
feature_name: feature_name,
values: Flipper::GateValues.new(boolean: bool),
thing: Flipper::Types::Actor.new(Flipper::Actor.new(1))
)
end
describe '#enabled?' do
context 'for true value' do
it 'returns true' do
expect(subject.enabled?(true)).to eq(true)
end
end
context 'for false value' do
it 'returns false' do
expect(subject.enabled?(false)).to eq(false)
end
end
end
describe '#open?' do
context 'for true value' do
it 'returns true' do
expect(subject.open?(context(true))).to be(true)
end
end
context 'for false value' do
it 'returns false' do
expect(subject.open?(context(false))).to be(false)
end
end
end
describe '#protects?' do
it 'returns true for boolean type' do
expect(subject.protects?(Flipper::Types::Boolean.new(true))).to be(true)
end
it 'returns true for true' do
expect(subject.protects?(true)).to be(true)
end
it 'returns true for false' do
expect(subject.protects?(false)).to be(true)
end
end
describe '#wrap' do
it 'returns boolean type for boolean type' do
expect(subject.wrap(Flipper::Types::Boolean.new(true)))
.to be_instance_of(Flipper::Types::Boolean)
end
it 'returns boolean type for true' do
expect(subject.wrap(true)).to be_instance_of(Flipper::Types::Boolean)
expect(subject.wrap(true).value).to be(true)
end
it 'returns boolean type for true' do
expect(subject.wrap(false)).to be_instance_of(Flipper::Types::Boolean)
expect(subject.wrap(false).value).to be(false)
end
end
end
|