fkocherga-cmd_line_test 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/cmd_line_test.gemspec +2 -2
- data/test/cli_app.rb +6 -0
- data/test/test.rb +19 -0
- data/test/test_helper.rb +1 -1
- metadata +2 -2
data/VERSION.yml
CHANGED
data/cmd_line_test.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cmd_line_test}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Fedor Kocherga"]
|
9
|
-
s.date = %q{2009-09-
|
9
|
+
s.date = %q{2009-09-17}
|
10
10
|
s.description = %q{Macros specific to command line Ruby apps testing. Works with Test::Unit or Shoulda.
|
11
11
|
}
|
12
12
|
s.email = %q{fkocherga@gmail.com}
|
data/test/cli_app.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
|
3
3
|
module CliApp
|
4
|
+
class CliException < StandardError
|
5
|
+
end
|
4
6
|
class <<self
|
5
7
|
def run
|
6
8
|
OptionParser.new do |opts|
|
@@ -10,6 +12,10 @@ module CliApp
|
|
10
12
|
puts option
|
11
13
|
end
|
12
14
|
|
15
|
+
opts.on( "--raise", "raise CliException") do
|
16
|
+
raise CliException, "CLI exception"
|
17
|
+
end
|
18
|
+
|
13
19
|
opts.on_tail("-h", "--help", "show help") do
|
14
20
|
puts opts
|
15
21
|
#exit NB!
|
data/test/test.rb
CHANGED
@@ -24,6 +24,25 @@ class CliUsageTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
run_with_options ["--invalid-option"], "running with invalid option" do
|
26
26
|
assert_failed_run
|
27
|
+
exception_raised = false
|
28
|
+
begin
|
29
|
+
assert_successful_run
|
30
|
+
rescue Exception
|
31
|
+
exception_raised = true
|
32
|
+
end
|
33
|
+
assert(exception_raised)
|
34
|
+
end
|
35
|
+
|
36
|
+
run_with_options ["--raise"], "raise exception" do
|
37
|
+
assert_failed_run
|
38
|
+
exception_raised = false
|
39
|
+
begin
|
40
|
+
assert_successful_run
|
41
|
+
rescue StandardError => error
|
42
|
+
assert error.to_s =~ /CLI exception/
|
43
|
+
exception_raised = true
|
44
|
+
end
|
45
|
+
assert(exception_raised)
|
27
46
|
end
|
28
47
|
end
|
29
48
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fkocherga-cmd_line_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fedor Kocherga
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|