|
21 | 21 | expect { subject.get_multi([feature]) }.to raise_error(Flipper::Adapters::Strict::NotFound) |
22 | 22 | end |
23 | 23 | end |
| 24 | + |
| 25 | + context "#add" do |
| 26 | + it "raises an error for unknown feature" do |
| 27 | + expect { subject.add(feature) }.to raise_error(Flipper::Adapters::Strict::NotFound) |
| 28 | + end |
| 29 | + end |
24 | 30 | end |
25 | 31 | end |
26 | 32 |
|
27 | 33 | context "handler = :warn" do |
28 | 34 | subject { described_class.new(Flipper::Adapters::Memory.new, :warn) } |
29 | 35 |
|
30 | 36 | context "#get" do |
31 | | - it "raises an error for unknown feature" do |
| 37 | + it "warns for unknown feature" do |
32 | 38 | expect(capture_output { subject.get(feature) }).to match(/Could not find feature "unknown"/) |
33 | 39 | end |
34 | 40 | end |
35 | 41 |
|
36 | 42 | context "#get_multi" do |
37 | | - it "raises an error for unknown feature" do |
| 43 | + it "warns for unknown feature" do |
38 | 44 | expect(capture_output { subject.get_multi([feature]) }).to match(/Could not find feature "unknown"/) |
39 | 45 | end |
40 | 46 | end |
| 47 | + |
| 48 | + context "#add" do |
| 49 | + it "warns for unknown feature" do |
| 50 | + expect(capture_output { subject.add(feature) }).to match(/Could not find feature "unknown"/) |
| 51 | + end |
| 52 | + end |
41 | 53 | end |
42 | 54 |
|
43 | 55 | context "handler = Block" do |
|
48 | 60 |
|
49 | 61 |
|
50 | 62 | context "#get" do |
51 | | - it "raises an error for unknown feature" do |
| 63 | + it "calls block for unknown feature" do |
52 | 64 | subject.get(feature) |
53 | 65 | expect(unknown_features).to eq(["unknown"]) |
54 | 66 | end |
55 | 67 | end |
56 | 68 |
|
57 | 69 | context "#get_multi" do |
58 | | - it "raises an error for unknown feature" do |
| 70 | + it "calls block for unknown feature" do |
59 | 71 | subject.get_multi([flipper[:foo], flipper[:bar]]) |
60 | 72 | expect(unknown_features).to eq(["foo", "bar"]) |
61 | 73 | end |
62 | 74 | end |
| 75 | + |
| 76 | + context "#add" do |
| 77 | + it "calls block for unknown feature" do |
| 78 | + subject.add(feature) |
| 79 | + expect(unknown_features).to eq(["unknown"]) |
| 80 | + end |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + describe ".with_sync_mode" do |
| 85 | + subject { described_class.new(Flipper::Adapters::Memory.new, :raise) } |
| 86 | + |
| 87 | + it "bypasses strict checks for add" do |
| 88 | + described_class.with_sync_mode do |
| 89 | + expect { subject.add(feature) }.not_to raise_error |
| 90 | + end |
| 91 | + end |
| 92 | + |
| 93 | + it "bypasses strict checks for get" do |
| 94 | + described_class.with_sync_mode do |
| 95 | + expect { subject.get(feature) }.not_to raise_error |
| 96 | + end |
| 97 | + end |
| 98 | + |
| 99 | + it "bypasses strict checks for get_multi" do |
| 100 | + described_class.with_sync_mode do |
| 101 | + expect { subject.get_multi([feature]) }.not_to raise_error |
| 102 | + end |
| 103 | + end |
| 104 | + |
| 105 | + it "restores previous sync mode after block" do |
| 106 | + described_class.with_sync_mode do |
| 107 | + # inside sync mode |
| 108 | + end |
| 109 | + expect { subject.add(feature) }.to raise_error(Flipper::Adapters::Strict::NotFound) |
| 110 | + end |
| 111 | + |
| 112 | + it "restores previous sync mode even on error" do |
| 113 | + begin |
| 114 | + described_class.with_sync_mode do |
| 115 | + raise "boom" |
| 116 | + end |
| 117 | + rescue RuntimeError |
| 118 | + end |
| 119 | + expect { subject.add(feature) }.to raise_error(Flipper::Adapters::Strict::NotFound) |
| 120 | + end |
63 | 121 | end |
64 | 122 | end |
0 commit comments