summaryrefslogtreecommitdiff
path: root/test/error_test.rb
diff options
context:
space:
mode:
authorsigurdsvela <sigurdbergsvela@gmail.com>2015-04-06 23:13:46 +0200
committersigurdsvela <sigurdbergsvela@gmail.com>2015-04-06 23:13:46 +0200
commit48d1aec2c4a42493ea06da0302538dc9ac834695 (patch)
tree32cc2e91f5aede4371a1bab414be243589011ff5 /test/error_test.rb
parent877946b0a16607bec39dcd437d30e7bb0afa4600 (diff)
downloadslop-48d1aec2c4a42493ea06da0302538dc9ac834695.tar.gz
Implement getUnknownMessage in UnknownOption
This allows to retrive the unknown option in question when catching the error. This can be useful to, for example, taylor a spesific output for common errors amongst users.
Diffstat (limited to 'test/error_test.rb')
-rw-r--r--test/error_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/error_test.rb b/test/error_test.rb
index 6a33c04..7ea30fc 100644
--- a/test/error_test.rb
+++ b/test/error_test.rb
@@ -21,6 +21,13 @@ describe Slop::UnknownOption do
opts = Slop::Options.new
opts.string "-n", "--name"
assert_raises(Slop::UnknownOption) { opts.parse %w(--foo) }
+
+ #Assert returns the unknown option in quetion
+ begin
+ opts.parse %w(--foo)
+ rescue Slop::UnknownOption => e
+ assert_equal(e.getUnknowOption(), "--foo");
+ end
end
it "does not raise when errors are suppressed" do