spec/flipper/dsl_spec.rb in flipper-0.11.0.beta1 vs spec/flipper/dsl_spec.rb in flipper-0.11.0.beta3
- old
+ new
@@ -105,11 +105,11 @@
end
describe '#actor' do
context 'for a thing' do
it 'returns actor instance' do
- thing = Struct.new(:flipper_id).new(33)
+ thing = Flipper::Actor.new(33)
actor = subject.actor(thing)
expect(actor).to be_instance_of(Flipper::Types::Actor)
expect(actor.value).to eq('33')
end
end
@@ -202,11 +202,11 @@
end
end
describe '#enable_actor/disable_actor' do
it 'enables and disables the feature for actor' do
- actor = Struct.new(:flipper_id).new(5)
+ actor = Flipper::Actor.new(5)
expect(subject[:stats].actors_value).to be_empty
subject.enable_actor(:stats, actor)
expect(subject[:stats].actors_value).to eq(Set['5'])
@@ -215,11 +215,11 @@
end
end
describe '#enable_group/disable_group' do
it 'enables and disables the feature for group' do
- actor = Struct.new(:flipper_id).new(5)
+ actor = Flipper::Actor.new(5)
group = Flipper.register(:fives) { |actor| actor.flipper_id == 5 }
expect(subject[:stats].groups_value).to be_empty
subject.enable_group(:stats, :fives)
expect(subject[:stats].groups_value).to eq(Set['fives'])
@@ -249,15 +249,30 @@
subject.disable_percentage_of_actors(:stats)
expect(subject[:stats].percentage_of_actors_value).to be(0)
end
end
+ describe '#add' do
+ it 'adds the feature' do
+ expect(subject.features).to eq(Set.new)
+ subject.add(:stats)
+ expect(subject.features).to eq(Set[subject[:stats]])
+ end
+ end
+
describe '#remove' do
it 'removes the feature' do
- subject.enable(:stats)
+ subject.adapter.add(subject[:stats])
+ expect(subject.features).to eq(Set[subject[:stats]])
+ subject.remove(:stats)
+ expect(subject.features).to eq(Set.new)
+ end
+ end
- expect { subject.remove(:stats) }.to change { subject.enabled?(:stats) }.to(false)
-
- expect(subject.features).to be_empty
+ describe '#import' do
+ it 'delegates to adapter' do
+ destination_flipper = build_flipper
+ expect(subject.adapter).to receive(:import).with(destination_flipper.adapter)
+ subject.import(destination_flipper)
end
end
end