2018-08-08 15:39:18 +02:00
|
|
|
describe Champs::CheckboxChamp do
|
2023-01-05 12:18:27 +01:00
|
|
|
it_behaves_like "a boolean champ" do
|
2024-04-05 10:34:01 +02:00
|
|
|
let(:boolean_champ) { build(:champ_checkbox, value: value) }
|
2023-01-05 12:18:27 +01:00
|
|
|
end
|
2018-08-08 15:39:18 +02:00
|
|
|
|
2023-01-05 12:18:27 +01:00
|
|
|
# TODO remove when normalize_checkbox_values is over
|
|
|
|
describe '#true?' do
|
2024-04-05 10:34:01 +02:00
|
|
|
let(:checkbox_champ) { build(:champ_checkbox, value: value) }
|
2023-01-05 12:18:27 +01:00
|
|
|
subject { checkbox_champ.true? }
|
2018-08-08 15:39:18 +02:00
|
|
|
|
2023-01-05 12:18:27 +01:00
|
|
|
context "when the checkbox value is 'on'" do
|
2018-08-08 15:39:18 +02:00
|
|
|
let(:value) { 'on' }
|
|
|
|
|
2023-01-05 12:18:27 +01:00
|
|
|
it { is_expected.to eq(true) }
|
2018-08-08 15:39:18 +02:00
|
|
|
end
|
|
|
|
|
2023-01-05 12:18:27 +01:00
|
|
|
context "when the checkbox value is 'off'" do
|
2018-08-08 15:39:18 +02:00
|
|
|
let(:value) { 'off' }
|
|
|
|
|
2023-01-05 12:18:27 +01:00
|
|
|
it { is_expected.to eq(false) }
|
2018-08-08 15:39:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|