Sha256: a0389e8bb25aaaccea8dd8faa7e85d4f11593e56e731a534ff47f7d2251610c0
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
require 'spec' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster') require 'cotta/command_interface' module BuildMaster describe CommandInterface do it 'delegate output to io' do io = mock('io') io.should_receive(:puts).with('content to output') interface = CommandInterface.new(io) interface.puts('content to output') end it 'prompt outputs a message and get the response from io' do io = mock('io') io.should_receive(:puts).with('question') io.should_receive(:gets).and_return('answer') interface = CommandInterface.new(io) actual = interface.prompt('question') actual.should == 'answer' end it 'prompt for choice' do io = mock('io') io.should_receive(:puts).once.with('select one of the following') io.should_receive(:puts).once.with('[1] item one') io.should_receive(:puts).once.with('[2] item two') io.should_receive(:gets).once.and_return('2') interface = CommandInterface.new(io) actual = interface.prompt_for_choice('select one of the following', ['item one', 'item two']) actual.should == 'item two' end it 'prompt for choice returns nil for invalid choice' do io = mock('io') io.should_receive(:puts).with('select one') io.should_receive(:puts).exactly(2).times io.should_receive(:gets).and_return('9') interface = CommandInterface.new(io) actual = interface.prompt_for_choice('select one', ['one', 'two']) actual.should be_nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
BuildMaster-1.1.9 | test/buildmaster/cotta/tc_command_interface.rb |