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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
RSpec.describe Flipper::UI::Configuration do
let(:configuration) { described_class.new }
describe "#delete" do
it "has default text" do
expect(configuration.delete.title).to eq("Danger Zone")
expect(configuration.delete.description).to eq("Deleting a feature removes it from the list of features and disables it for everyone.")
end
end
describe "#banner_text" do
it "has no default" do
expect(configuration.banner_text).to eq(nil)
end
it "can be updated" do
configuration.banner_text = 'Production Environment'
expect(configuration.banner_text).to eq('Production Environment')
end
end
describe "#banner_class" do
it "has default color" do
expect(configuration.banner_class).to eq('danger')
end
it "can be updated" do
configuration.banner_class = 'info'
expect(configuration.banner_class).to eq('info')
end
it "raises if set to invalid value" do
expect { configuration.banner_class = :invalid_class }
.to raise_error(Flipper::InvalidConfigurationValue)
end
end
describe "#application_breadcrumb_href" do
it "has default value" do
expect(configuration.application_breadcrumb_href).to eq(nil)
end
it "can be updated" do
configuration.application_breadcrumb_href = 'http://www.myapp.com'
expect(configuration.application_breadcrumb_href).to eq('http://www.myapp.com')
end
end
describe "#feature_creation_enabled" do
it "has default value" do
expect(configuration.feature_creation_enabled).to eq(true)
end
it "can be updated" do
configuration.feature_creation_enabled = false
expect(configuration.feature_creation_enabled).to eq(false)
end
end
describe "#cloud_recommendation" do
it "has default value" do
expect(configuration.cloud_recommendation).to eq(true)
end
it "can be updated" do
configuration.cloud_recommendation = false
expect(configuration.cloud_recommendation).to eq(false)
end
end
describe "#feature_removal_enabled" do
it "has default value" do
expect(configuration.feature_removal_enabled).to eq(true)
end
it "can be updated" do
configuration.feature_removal_enabled = false
expect(configuration.feature_removal_enabled).to eq(false)
end
end
describe "#fun" do
it "has default value" do
expect(configuration.fun).to eq(true)
end
it "can be updated" do
configuration.fun = false
expect(configuration.fun).to eq(false)
end
end
describe "#descriptions_source" do
it "has default value" do
expect(configuration.descriptions_source.call(%w[foo bar])).to eq({})
end
context "descriptions source is provided" do
it "can be updated" do
configuration.descriptions_source = lambda do |_keys|
YAML.load_file(FlipperRoot.join('spec/support/descriptions.yml'))
end
keys = %w[some_awesome_feature foo]
result = configuration.descriptions_source.call(keys)
expected = {
"some_awesome_feature" => "Awesome feature description",
}
expect(result).to eq(expected)
end
end
end
describe "#confirm_fully_enable" do
it "has default value" do
expect(configuration.confirm_fully_enable).to eq(false)
end
it "can be updated" do
configuration.confirm_fully_enable = true
expect(configuration.confirm_fully_enable).to eq(true)
end
end
describe "#show_feature_description_in_list" do
it "has default value" do
expect(configuration.show_feature_description_in_list).to eq(false)
end
it "can be updated" do
configuration.show_feature_description_in_list = true
expect(configuration.show_feature_description_in_list).to eq(true)
end
end
describe "#show_feature_description_in_list?" do
subject { configuration.show_feature_description_in_list? }
context 'when using_descriptions? is false and show_feature_description_in_list is false' do
it { is_expected.to eq(false) }
end
context 'when using_descriptions? is false and show_feature_description_in_list is true' do
before { configuration.show_feature_description_in_list = true }
it { is_expected.to eq(false) }
end
context 'when using_descriptions? is true and show_feature_description_in_list is false' do
before { allow(configuration).to receive(:using_descriptions?).and_return(true) }
it { is_expected.to eq(false) }
end
context 'when using_descriptions? is true and show_feature_description_in_list is true' do
before do
allow(configuration).to receive(:using_descriptions?).and_return(true)
configuration.show_feature_description_in_list = true
end
it { is_expected.to eq(true) }
end
end
end
|