fa6fc077b4
* extract parent for yes no and checkbox champs * checkbox stores true / false instead of on / off * normalize blank value to nil * normalize invalid value to false * after party task: normalize checkbox values * after party task: normalize yes_no values
23 lines
591 B
Ruby
23 lines
591 B
Ruby
describe Champs::CheckboxChamp do
|
|
it_behaves_like "a boolean champ" do
|
|
let(:boolean_champ) { Champs::CheckboxChamp.new(value: value) }
|
|
end
|
|
|
|
# TODO remove when normalize_checkbox_values is over
|
|
describe '#true?' do
|
|
let(:checkbox_champ) { Champs::CheckboxChamp.new(value: value) }
|
|
subject { checkbox_champ.true? }
|
|
|
|
context "when the checkbox value is 'on'" do
|
|
let(:value) { 'on' }
|
|
|
|
it { is_expected.to eq(true) }
|
|
end
|
|
|
|
context "when the checkbox value is 'off'" do
|
|
let(:value) { 'off' }
|
|
|
|
it { is_expected.to eq(false) }
|
|
end
|
|
end
|
|
end
|