spec/lib/cliprompt/optionset_spec.rb in cliprompt-0.0.6 vs spec/lib/cliprompt/optionset_spec.rb in cliprompt-0.1.0
- old
+ new
@@ -20,11 +20,11 @@
Given(:set) { Cliprompt::Optionset.new(options) }
When(:choices) { set.choices }
When(:default) { set.default }
When(:display) { set.display }
Then { expect(choices).to eq options }
- Then { expect(default).to be_false }
+ Then { expect(default).to be_falsey }
Then { expect(set.display).to eq '(xxx / yyy / zzz) ' }
end
context "when there is a default specified (#{['xxx', '=yyy', 'zzz'].to_s})," do
Given(:options) { ['xxx', 'yyy', 'zzz'] }
@@ -43,11 +43,11 @@
Given(:set) { Cliprompt::Optionset.new(options) }
When(:choices) { set.choices }
When(:default) { set.default }
When(:display) { set.display }
Then { expect(choices).to eq options.map(&:to_s) }
- Then { expect(default).to be_false }
+ Then { expect(default).to be_falsey }
Then { expect(display).to eq '(22 / yyy / zzz) ' }
end
end
describe '.parse_hash' do
@@ -80,32 +80,32 @@
Given(:options) { { boolean: true } }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
When(:boolean) { set.boolean }
- Then { expect(default).to be_true }
- Then { expect(boolean).to be_true }
+ Then { expect(default).to be_truthy }
+ Then { expect(boolean).to be_truthy }
Then { expect(display).to eq '[Y/n] ' }
end
context 'when default is given as true, default booean is Y,' do
Given(:options) { { boolean: true, default: true } }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
When(:boolean) { set.boolean }
- Then { expect(default).to be_true }
- Then { expect(boolean).to be_true }
+ Then { expect(default).to be_truthy }
+ Then { expect(boolean).to be_truthy }
Then { expect(display).to eq '[Y/n] ' }
end
context 'when default is given as false, default boolean is N,' do
Given(:options) { { boolean: true, default: false } }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
When(:boolean) { set.boolean }
- Then { expect(default).to be_false }
- Then { expect(boolean).to be_true }
+ Then { expect(default).to be_falsey }
+ Then { expect(boolean).to be_truthy }
Then { expect(display).to eq '[y/N] ' }
end
end
end
@@ -139,52 +139,52 @@
Given(:options) { 'yesno' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
When(:boolean) { set.boolean }
- Then { expect(default).to be_true }
- Then { expect(boolean).to be_true }
+ Then { expect(default).to be_truthy }
+ Then { expect(boolean).to be_truthy }
Then { expect(display).to eq '[Y/n] ' }
end
context 'when using yn,' do
Given(:options) { 'yn' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
- Then { expect(default).to be_true }
+ Then { expect(default).to be_truthy }
Then { expect(display).to eq '[Y/n] ' }
end
context 'when using YN,' do
Given(:options) { 'YN' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
- Then { expect(default).to be_true }
+ Then { expect(default).to be_truthy }
Then { expect(display).to eq '[Y/n] ' }
end
context 'when using yesNo,' do
Given(:options) { 'yesNo' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
- Then { expect(default).to be_false }
+ Then { expect(default).to be_falsey }
Then { expect(display).to eq '[y/N] ' }
end
context 'when using yN,' do
Given(:options) { 'yesNo' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
- Then { expect(default).to be_false }
+ Then { expect(default).to be_falsey }
Then { expect(display).to eq '[y/N] ' }
end
context 'when using y/N,' do
Given(:options) { 'yesNo' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
When(:display) { set.display }
- Then { expect(default).to be_false }
+ Then { expect(default).to be_falsey }
Then { expect(display).to eq '[y/N] ' }
end
end
end
@@ -247,22 +247,22 @@
Then { expect(set).to receive(:ask_again).with(question, msg) }
And { expect{ set.check_boolean(question, input) }.not_to raise_error }
end
context 'when a no answer is given,' do
When(:input) { 'no' }
- Then { expect(set.check_boolean(question, input)).to be_false }
+ Then { expect(set.check_boolean(question, input)).to be_falsey }
end
context 'when a N answer is given,' do
When(:input) { 'N' }
- Then { expect(set.check_boolean(question, input)).to be_false }
+ Then { expect(set.check_boolean(question, input)).to be_falsey }
end
context 'when a yes answer is given,' do
When(:input) { 'yes' }
- Then { expect(set.check_boolean(question, input)).to be_true }
+ Then { expect(set.check_boolean(question, input)).to be_truthy }
end
context 'when a Y answer is given,' do
When(:input) { 'Y' }
- Then { expect(set.check_boolean(question, input)).to be_true }
+ Then { expect(set.check_boolean(question, input)).to be_truthy }
end
end
describe '.check_choices' do
Given(:question) { 'so what?' }