Skip to content

Commit 9841c7d

Browse files
committed
Add failing spec for Shell::Basic#no? when called with misc. data.
1 parent 09ae066 commit 9841c7d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/shell/basic_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def shell
7373
expect($stdin).to receive(:gets).and_return('n')
7474
expect(shell.yes?("Should I overwrite it?")).not_to be_true
7575
end
76+
77+
it "asks the user and returns false if the user replies with an answer other than yes or no" do
78+
expect($stdout).to receive(:print).with("Should I overwrite it? ")
79+
expect($stdin).to receive(:gets).and_return('foobar')
80+
expect(shell.yes?("Should I overwrite it?")).to be_false
81+
end
7682
end
7783

7884
describe "#no?" do
@@ -85,6 +91,12 @@ def shell
8591
expect($stdin).to receive(:gets).and_return('Yes')
8692
expect(shell.no?("Should I overwrite it?")).to be_false
8793
end
94+
95+
it "asks the user and returns false if the user replies with an answer other than yes or no" do
96+
expect($stdout).to receive(:print).with("Should I overwrite it? ")
97+
expect($stdin).to receive(:gets).and_return('foobar')
98+
expect(shell.no?("Should I overwrite it?")).to be_false
99+
end
88100
end
89101

90102
describe "#say" do

0 commit comments

Comments
 (0)