spec/kata_base_spec.rb in kata-1.3.3 vs spec/kata_base_spec.rb in kata-1.4.0

- old
+ new

@@ -12,36 +12,66 @@ subject { use_class.new } let(:system_call) {"git add . && git commit -m 'test req' > /dev/null"} + describe "#questions" do + it "individually displays question" do + expect(subject).to receive(:puts).with("\nQuestions:") + expect(subject).to receive(:puts).with(" - test question 1?") + expect(subject).to receive(:puts).with(" - test question 2?") + + subject.questions do + subject.question "test question 1" + subject.question "test question 2" + end + end + + it "ignores trailing question mark" do + expect(subject).to receive(:puts).with("\nQuestions:") + expect(subject).to receive(:puts).with(" - test question 1?") + expect(subject).to receive(:puts).with(" - test question 2?") + + subject.questions do + subject.question "test question 1?" + subject.question "test question 2?" + end + end + + it "ignores questions when none provided" do + expect(subject).to_not receive(:puts) + + subject.questions + end + end + describe "#kata" do it 'displays summary' do - subject.should_receive(:puts).with('test Kata') + expect(subject).to receive(:puts).with('test Kata') subject.kata 'test' end end describe '#context' do it 'displays' do - subject.should_receive(:puts).with('test Kata') - subject.should_receive(:puts).with(' test context') + expect(subject).to receive(:puts).with('test Kata') + expect(subject).to receive(:puts).with(' test context') subject.kata 'test' do subject.context 'test context' end end it 'accepts requirement' do - subject.should_receive(:puts).with(' test context') - subject.should_receive(:puts).with(' test req') - subject.should_receive(:print) - $stdin.should_receive(:gets).and_return('y') - subject.should_receive(:puts).exactly(2).times - subject.should_receive(:system).with(system_call).and_return(0) - subject.should_receive(:puts) + expect(subject).to receive(:puts).with(' test context') + expect(subject).to receive(:puts).with(' test req') + expect(subject).to receive(:print) + expect($stdin).to receive(:gets).and_return('y') + expect(subject).to receive(:puts).exactly(2).times + expect(subject).to receive(:system).with(system_call).and_return(0) + expect(subject).to receive(:puts) subject.kata 'test' do subject.context 'test context' do subject.requirement 'test req' end @@ -49,30 +79,30 @@ end end describe '#requirement' do it 'displays' do - subject.should_receive(:puts).with(' test req') - subject.should_receive(:print) - $stdin.should_receive(:gets).and_return('y') - subject.should_receive(:puts).exactly(2).times - subject.should_receive(:system).with(system_call).and_return(0) - subject.should_receive(:puts) + expect(subject).to receive(:puts).with(' test req') + expect(subject).to receive(:print) + expect($stdin).to receive(:gets).and_return('y') + expect(subject).to receive(:puts).exactly(2).times + expect(subject).to receive(:system).with(system_call).and_return(0) + expect(subject).to receive(:puts) subject.kata 'test' do subject.requirement 'test req' end end it 'accepts example' do - subject.should_receive(:puts).with(' test req') - subject.should_receive(:print) - $stdin.should_receive(:gets).and_return('y') - subject.should_receive(:puts).exactly(2).times - subject.should_receive(:system).with(system_call).and_return(0) - subject.should_receive(:puts).exactly(3).times - subject.should_receive(:puts) + expect(subject).to receive(:puts).with(' test req') + expect(subject).to receive(:print) + expect($stdin).to receive(:gets).and_return('y') + expect(subject).to receive(:puts).exactly(2).times + expect(subject).to receive(:system).with(system_call).and_return(0) + expect(subject).to receive(:puts).exactly(3).times + expect(subject).to receive(:puts) subject.kata 'test' do subject.requirement 'test req' do subject.example 'test example 1' subject.example 'test example 2' @@ -80,16 +110,16 @@ end end end it 'accepts detail' do - subject.should_receive(:puts).with(' test req') - subject.should_receive(:print) - $stdin.should_receive(:gets).and_return('y') - subject.should_receive(:puts).exactly(2).times - subject.should_receive(:system).with(system_call).and_return(0) - subject.should_receive(:puts).exactly(3).times - subject.should_receive(:puts) + expect(subject).to receive(:puts).with(' test req') + expect(subject).to receive(:print) + expect($stdin).to receive(:gets).and_return('y') + expect(subject).to receive(:puts).exactly(2).times + expect(subject).to receive(:system).with(system_call).and_return(0) + expect(subject).to receive(:puts).exactly(3).times + expect(subject).to receive(:puts) subject.kata 'test' do subject.requirement 'test req' do subject.detail 'test detail 1' subject.detail 'test detail 2'