spec/lib/cliprompt_spec.rb in cliprompt-0.0.2 vs spec/lib/cliprompt_spec.rb in cliprompt-0.0.3

- old
+ new

@@ -31,9 +31,27 @@ Then { expect(subject.ask(question, args)).to eq answer } And { expect(output.string).to eq "#{question} " } end end + describe '.guess' do + Given(:question) { 'wazza?' } + Given(:env_var) { 'SOMEVAR' } + Given(:args) { } + context 'when env var is provided,' do + When(:env_value) { 'xxx' } + When { ENV[env_var] = env_value } + Then { expect(subject.guess(env_var, question, args)).to eq env_value } + And { ENV.delete(env_var) } + end + context 'when env var is not provided,' do + When(:answer) { 'ooo' } + When { input.stub(:gets).and_return answer } + Then { expect(subject.guess(env_var, question, args)).to eq answer } + And { expect(output.string).to eq "#{question} " } + end + end + describe '.say' do Given(:msg) { "hah" } When { subject.say msg } Then { expect(output.string).to eq "#{msg}\n" } end