Permalink
Browse files

make sure we're dealing with true/false, not values such as 0 which a…

…re still true
  • Loading branch information...
1 parent 238fe58 commit be0a24def20633a43a11f142351564cf34ee363d @jackdempsey jackdempsey committed Sep 10, 2010
Showing with 5 additions and 5 deletions.
  1. +1 −1 lib/thor/shell/basic.rb
  2. +4 −4 spec/shell/basic_spec.rb
View
@@ -69,7 +69,7 @@ def say_status(status, message, log_status=true)
# "yes".
#
def yes?(statement, color=nil)
- ask(statement, color) =~ is?(:yes)
+ !!(ask(statement, color) =~ is?(:yes))
end
# Make a question the to user and returns true if the user replies "n" or
View
@@ -27,23 +27,23 @@ def shell
it "asks the user and returns true if the user replies yes" do
$stdout.should_receive(:print).with("Should I overwrite it? ")
$stdin.should_receive(:gets).and_return('y')
- shell.yes?("Should I overwrite it?").must be_true
+ shell.yes?("Should I overwrite it?").must === true
$stdout.should_receive(:print).with("Should I overwrite it? ")
$stdin.should_receive(:gets).and_return('n')
- shell.yes?("Should I overwrite it?").must_not be_true
+ shell.yes?("Should I overwrite it?").must_not === true
end
end
describe "#no?" do
it "asks the user and returns true if the user replies no" do
$stdout.should_receive(:print).with("Should I overwrite it? ")
$stdin.should_receive(:gets).and_return('n')
- shell.no?("Should I overwrite it?").must be_true
+ shell.no?("Should I overwrite it?").must === true
$stdout.should_receive(:print).with("Should I overwrite it? ")
$stdin.should_receive(:gets).and_return('Yes')
- shell.no?("Should I overwrite it?").must be_false
+ shell.no?("Should I overwrite it?").must === false
end
end

0 comments on commit be0a24d

Please sign in to comment.