spec/lib/cliprompt/optionset_spec.rb in cliprompt-0.0.4 vs spec/lib/cliprompt/optionset_spec.rb in cliprompt-0.0.5
- old
+ new
@@ -21,11 +21,11 @@
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(display).to eq '(xxx / yyy / zzz)' }
+ 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'] }
Given(:options_with_default) { ['xxx', '=yyy', 'zzz'] }
@@ -33,22 +33,22 @@
When(:choices) { set.choices }
When(:default) { set.default }
When(:display) { set.display }
Then { expect(choices).to eq options }
Then { expect(default).to eq 'yyy' }
- Then { expect(display).to eq '(xxx / yyy / zzz)[yyy]' }
+ Then { expect(display).to eq '(xxx / yyy / zzz) [yyy] ' }
end
context "when there is a mixed numeric and string choices (#{[22, 'yyy', 'zzz'].to_s})," do
Given(:options) { [22, 'yyy', 'zzz'] }
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(display).to eq '(22 / yyy / zzz)' }
+ Then { expect(display).to eq '(22 / yyy / zzz) ' }
end
end
describe '.parse_hash' do
@@ -59,54 +59,54 @@
When(:choices) { set.choices }
When(:default) { set.default }
When(:display) { set.display }
Then { expect(choices).to eq ['xxx', 'yyy', 'zzz'] }
Then { expect(default).to eq 'xxx' }
- Then { expect(display).to eq '(xxx / yyy / zzz)[xxx]' }
+ Then { expect(display).to eq '(xxx / yyy / zzz) [xxx] ' }
end
context "when using string keys (#{{ 'default' => 'xxx', 'choices' => ['xxx', 'yyy', 'zzz'] }.to_s})," do
Given(:options) { { 'default' => 'xxx', 'choices' => ['xxx', 'yyy', 'zzz'] } }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:choices) { set.choices }
When(:default) { set.default }
When(:display) { set.display }
Then { expect(choices).to eq ['xxx', 'yyy', 'zzz'] }
Then { expect(default).to eq 'xxx' }
- Then { expect(display).to eq '(xxx / yyy / zzz)[xxx]' }
+ Then { expect(display).to eq '(xxx / yyy / zzz) [xxx] ' }
end
end
context 'when there is only boolean,' do
- context 'when no default is given, default booean is Y,' do
+ context 'when no default is given, default booean is Y,' do
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(display).to eq '[Y/n]' }
+ 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(display).to eq '[Y/n]' }
+ 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(display).to eq '[y/N]' }
+ Then { expect(display).to eq '[y/N] ' }
end
end
end
describe '.parse_fixnum' do
@@ -127,11 +127,13 @@
context 'when a random string is passed, it is the default,' do
Given(:options) { 'something' }
Given(:set) { Cliprompt::Optionset.new(options) }
When(:default) { set.default }
+ When(:display) { set.display }
Then { expect(default).to eq options }
+ Then { expect(display).to eq '[something] ' }
end
context 'when a "yesno" kind of string is passed,' do
context 'when using yesno,' do
Given(:options) { 'yesno' }
@@ -139,50 +141,50 @@
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(display).to eq '[Y/n]' }
+ 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(display).to eq '[Y/n]' }
+ 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(display).to eq '[Y/n]' }
+ 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(display).to eq '[y/N]' }
+ 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(display).to eq '[y/N]' }
+ 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(display).to eq '[y/N]' }
+ Then { expect(display).to eq '[y/N] ' }
end
end
end