summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-12-07 11:47:18 -0800
committerTim Smith <tsmith@chef.io>2017-12-07 13:27:30 -0800
commit6cf225b7e4b9e3cb788e3998d4c54f32e55ea9df (patch)
tree2413c43d39359870c8d824cd951ad99f9d700ac9
parent6ad0ac95c33969a16b79fd32cd987fe68c150266 (diff)
downloadchef-6cf225b7e4b9e3cb788e3998d4c54f32e55ea9df.tar.gz
Improve the integer/string warning message
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/windows_task.rb4
-rw-r--r--spec/functional/resource/windows_task_spec.rb2
-rw-r--r--spec/unit/resource/windows_task_spec.rb8
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index 7e9025aea1..9fd7db7f53 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -72,7 +72,7 @@ class Chef
if execution_time_limit
unless execution_time_limit == "PT72H" # don't double convert an iso08601 format duration
- raise ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds an Integer or a String with numeric values only e.g. '60'." unless numeric_value_in_string?(execution_time_limit)
+ raise ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60')." unless numeric_value_in_string?(execution_time_limit)
duration = sec_to_dur(execution_time_limit)
execution_time_limit(duration)
end
@@ -101,7 +101,7 @@ class Chef
raise ArgumentError, "`random_delay` property is supported only for frequency :minute, :hourly, :daily, :weekly and :monthly"
end
- raise ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds an Integer or a String with numeric values only e.g. '60'." unless numeric_value_in_string?(random_delay)
+ raise ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60')." unless numeric_value_in_string?(random_delay)
end
def validate_start_day(start_day, frequency)
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index b6e6540693..b9aa6c6568 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -308,7 +308,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
it "raises error if invalid random_delay is passed" do
subject.frequency :minute
subject.random_delay "abc"
- expect { subject.after_created }.to raise_error("Invalid value passed for `random_delay`. Please pass seconds as a String e.g. '60'.")
+ expect { subject.after_created }.to raise_error("Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
end
it "raises error if random_delay is passed with frequency on_idle" do
diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb
index 725aa0fd86..21de8c6fb6 100644
--- a/spec/unit/resource/windows_task_spec.rb
+++ b/spec/unit/resource/windows_task_spec.rb
@@ -89,13 +89,13 @@ describe Chef::Resource::WindowsTask do
it "raises error for invalid random_delay" do
resource.frequency :monthly
resource.random_delay "xyz"
- expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds an Integer or a String with numeric values only e.g. '60'.")
+ expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
end
it "raises error for invalid random_delay which looks like an Integer" do
resource.frequency :monthly
resource.random_delay "5,000"
- expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds an Integer or a String with numeric values only e.g. '60'.")
+ expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
end
it "converts seconds String into iso8601 duration format" do
@@ -123,12 +123,12 @@ describe Chef::Resource::WindowsTask do
context "when execution_time_limit is passed" do
it "raises error for invalid execution_time_limit" do
resource.execution_time_limit "abc"
- expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds an Integer or a String with numeric values only e.g. '60'.")
+ expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
end
it "raises error for invalid execution_time_limit that looks like an Integer" do
resource.execution_time_limit "5,000"
- expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds an Integer or a String with numeric values only e.g. '60'.")
+ expect { resource.after_created }.to raise_error(Chef::Exceptions::ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
end
it "converts seconds Integer into iso8601 format" do