summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Maier <cm@opscode.com>2012-12-04 16:35:26 -0500
committerChristopher Maier <cm@opscode.com>2012-12-04 16:35:26 -0500
commit8e031f425b1c53edde6996e2f59b884028f1b9db (patch)
tree0e114bb010c0d34e0effd7760e0634bae7c8977f
parent149c4fba30c2fe37c5c9b74b14be8f238fd855c4 (diff)
downloadchef-8e031f425b1c53edde6996e2f59b884028f1b9db.tar.gz
Use ui.confirm in nag instead of custom logic
Removed tests for #nag, since now that amounts to testing ui.confirm.
-rw-r--r--lib/chef/knife/index_rebuild.rb8
-rw-r--r--spec/unit/knife/index_rebuild_spec.rb27
2 files changed, 1 insertions, 34 deletions
diff --git a/lib/chef/knife/index_rebuild.rb b/lib/chef/knife/index_rebuild.rb
index e1985e6457..e462f4b398 100644
--- a/lib/chef/knife/index_rebuild.rb
+++ b/lib/chef/knife/index_rebuild.rb
@@ -73,13 +73,7 @@ class Chef
end
def nag
- unless config[:yes]
- yea_or_nay = ask_question("This operation is destructive. Rebuilding the index may take some time. You sure? (yes/no): ")
- unless yea_or_nay =~ /^y/i
- puts "aborting"
- exit 7
- end
- end
+ ui.confirm("This operation is destructive. Rebuilding the index may take some time. You sure? (yes/no): ")
end
# Chef 11 (and above) servers return various pieces of
diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb
index 3c4751bf60..414ec95fad 100644
--- a/spec/unit/knife/index_rebuild_spec.rb
+++ b/spec/unit/knife/index_rebuild_spec.rb
@@ -82,33 +82,6 @@ describe Chef::Knife::IndexRebuild do
end
end # unsupported_version?
- context "#nag" do
-
- before :each do
- # Simulate user input at the command line
- knife.ui.stub!(:stdin).and_return(user_input)
- end
-
- context "with a NO response" do
- let(:user_input){StringIO.new("NO\n")}
- it "exits" do
- knife.should_receive(:exit).with(7)
- knife.should_receive(:puts).with("aborting")
- knife.nag
- end
- end
-
- context "with a YES response" do
- let(:user_input){StringIO.new("YES\n")}
- it "does not exit" do
- knife.should_not_receive(:exit)
- knife.nag
- end
- end
-
- end # nag
-
-
context "Simulating a 'knife index rebuild' run" do
before :each do