gli 2.9.0 → 2.20.0

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.
Files changed (94) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +28 -0
  3. data/.gitignore +3 -3
  4. data/.tool-versions +1 -0
  5. data/Gemfile +0 -2
  6. data/README.rdoc +29 -18
  7. data/Rakefile +15 -37
  8. data/bin/ci +29 -0
  9. data/bin/gli +24 -54
  10. data/bin/rake +29 -0
  11. data/bin/setup +5 -0
  12. data/exe/gli +68 -0
  13. data/gli.gemspec +20 -24
  14. data/gli.rdoc +9 -9
  15. data/lib/gli/app.rb +42 -8
  16. data/lib/gli/app_support.rb +17 -5
  17. data/lib/gli/argument.rb +20 -0
  18. data/lib/gli/command.rb +27 -2
  19. data/lib/gli/command_finder.rb +42 -25
  20. data/lib/gli/command_support.rb +13 -7
  21. data/lib/gli/commands/doc.rb +9 -3
  22. data/lib/gli/commands/help.rb +2 -1
  23. data/lib/gli/commands/help_modules/arg_name_formatter.rb +29 -2
  24. data/lib/gli/commands/help_modules/command_help_format.rb +19 -1
  25. data/lib/gli/commands/help_modules/full_synopsis_formatter.rb +5 -4
  26. data/lib/gli/commands/help_modules/global_help_format.rb +1 -1
  27. data/lib/gli/commands/help_modules/options_formatter.rb +4 -6
  28. data/lib/gli/commands/initconfig.rb +3 -6
  29. data/lib/gli/commands/rdoc_document_listener.rb +2 -1
  30. data/lib/gli/commands/scaffold.rb +71 -142
  31. data/lib/gli/dsl.rb +25 -1
  32. data/lib/gli/exceptions.rb +26 -0
  33. data/lib/gli/flag.rb +23 -2
  34. data/lib/gli/gli_option_parser.rb +73 -21
  35. data/lib/gli/option_parser_factory.rb +10 -3
  36. data/lib/gli/options.rb +2 -2
  37. data/lib/gli/switch.rb +4 -0
  38. data/lib/gli/terminal.rb +6 -2
  39. data/lib/gli/version.rb +1 -1
  40. data/lib/gli.rb +2 -0
  41. data/object-model.dot +29 -0
  42. data/object-model.png +0 -0
  43. data/test/apps/todo/Gemfile +1 -1
  44. data/test/apps/todo/bin/todo +16 -6
  45. data/test/apps/todo/lib/todo/commands/create.rb +48 -18
  46. data/test/apps/todo/lib/todo/commands/list.rb +48 -35
  47. data/test/apps/todo/lib/todo/commands/ls.rb +25 -24
  48. data/test/apps/todo/lib/todo/commands/make.rb +42 -39
  49. data/test/apps/todo/todo.gemspec +1 -2
  50. data/test/apps/todo_legacy/todo.gemspec +1 -2
  51. data/test/apps/todo_plugins/commands/third.rb +2 -0
  52. data/test/integration/gli_cli_test.rb +69 -0
  53. data/test/integration/gli_powered_app_test.rb +52 -0
  54. data/test/integration/scaffold_test.rb +30 -0
  55. data/test/integration/test_helper.rb +52 -0
  56. data/test/unit/command_finder_test.rb +54 -0
  57. data/test/{tc_command.rb → unit/command_test.rb} +20 -7
  58. data/test/unit/compound_command_test.rb +17 -0
  59. data/test/{tc_doc.rb → unit/doc_test.rb} +38 -51
  60. data/test/{tc_flag.rb → unit/flag_test.rb} +19 -25
  61. data/test/{tc_gli.rb → unit/gli_test.rb} +92 -49
  62. data/test/{tc_help.rb → unit/help_test.rb} +54 -113
  63. data/test/{init_simplecov.rb → unit/init_simplecov.rb} +0 -0
  64. data/test/{tc_options.rb → unit/options_test.rb} +4 -4
  65. data/test/unit/subcommand_parsing_test.rb +263 -0
  66. data/test/unit/subcommands_test.rb +245 -0
  67. data/test/{fake_std_out.rb → unit/support/fake_std_out.rb} +0 -0
  68. data/test/{config.yaml → unit/support/gli_test_config.yml} +1 -0
  69. data/test/unit/switch_test.rb +49 -0
  70. data/test/{tc_terminal.rb → unit/terminal_test.rb} +28 -3
  71. data/test/unit/test_helper.rb +13 -0
  72. data/test/unit/verbatim_wrapper_test.rb +24 -0
  73. metadata +86 -141
  74. data/.ruby-gemset +0 -1
  75. data/.ruby-version +0 -1
  76. data/.travis.yml +0 -12
  77. data/ObjectModel.graffle +0 -1191
  78. data/bin/report_on_rake_results +0 -10
  79. data/bin/test_all_rubies.sh +0 -6
  80. data/features/gli_executable.feature +0 -90
  81. data/features/gli_init.feature +0 -232
  82. data/features/step_definitions/gli_executable_steps.rb +0 -18
  83. data/features/step_definitions/gli_init_steps.rb +0 -11
  84. data/features/step_definitions/todo_steps.rb +0 -96
  85. data/features/support/env.rb +0 -54
  86. data/features/todo.feature +0 -449
  87. data/features/todo_legacy.feature +0 -128
  88. data/test/option_test_helper.rb +0 -13
  89. data/test/tc_compound_command.rb +0 -22
  90. data/test/tc_subcommand_parsing.rb +0 -104
  91. data/test/tc_subcommands.rb +0 -259
  92. data/test/tc_switch.rb +0 -55
  93. data/test/tc_verbatim_wrapper.rb +0 -36
  94. data/test/test_helper.rb +0 -20
@@ -0,0 +1,52 @@
1
+ require_relative "test_helper"
2
+ require "open3"
3
+
4
+ class GLIPoweredAppTest < MiniTest::Test
5
+ include TestHelper
6
+
7
+ def teardown
8
+ FileUtils.rm_f("todo.rdoc")
9
+ end
10
+
11
+ def test_help_works
12
+ out = run_app("help")
13
+ assert_top_level_help(out)
14
+ end
15
+
16
+ def test_unknown_command_exits_nonzero
17
+ out, err, status = run_app("asdfasdfasdf", expect_failure: true, return_err_and_status: true)
18
+ assert_match /Unknown command 'asdfasdfasdf'/,err
19
+ assert_equal 64, status.exitstatus
20
+ assert_top_level_help(out)
21
+ end
22
+
23
+ def test_unknown_switch_exits_nonzero
24
+ out, err, status = run_app("list --foo", expect_failure: true, return_err_and_status: true)
25
+ assert_match /Unknown option \-\-foo/,err
26
+ assert_equal 64, status.exitstatus
27
+ assert_match /COMMAND OPTIONS/, out
28
+ end
29
+
30
+ def test_missing_args_exits_nonzero
31
+ out, err, status = run_app("list", expect_failure: true, return_err_and_status: true)
32
+ assert_match /required_flag is required, required_flag2 is required/,err
33
+ assert_equal 64, status.exitstatus
34
+ assert_match /COMMAND OPTIONS/, out
35
+ end
36
+
37
+ def test_doc_generation
38
+ out, err, status = run_app("_doc", return_err_and_status: true)
39
+ assert File.exists?("todo.rdoc")
40
+ end
41
+
42
+ private
43
+ def assert_top_level_help(out)
44
+ assert_match /SYNOPSIS/, out
45
+ assert_match /GLOBAL OPTIONS/, out
46
+ assert_match /COMMANDS/, out
47
+ end
48
+
49
+ def run_app(args="", return_err_and_status: false, expect_failure: false)
50
+ run_command("test/apps/todo/bin/todo",args,return_err_and_status:return_err_and_status,expect_failure:expect_failure)
51
+ end
52
+ end
@@ -0,0 +1,30 @@
1
+ require_relative "test_helper"
2
+ require "open3"
3
+
4
+ class ScaffoldCommandTest < MiniTest::Test
5
+ include TestHelper
6
+
7
+ def test_scaffolded_app_has_reasonable_setup
8
+ FileUtils.rm_rf "scaffold_test"
9
+ run_gli("init scaffold_test")
10
+ assert Dir.exist? "scaffold_test"
11
+ FileUtils.chdir "scaffold_test" do
12
+ run_command("bundle install", "", return_err_and_status: false, expect_failure: false)
13
+
14
+ scaffold_lib = "lib:../lib"
15
+
16
+ # help works
17
+ out = run_command("bin/scaffold_test","--help", return_err_and_status: false, expect_failure: false, rubylib: scaffold_lib)
18
+ assert_match /SYNOPSIS/,out
19
+ assert_match /GLOBAL OPTIONS/,out
20
+ assert_match /COMMANDS/,out
21
+
22
+ # can run unit tests
23
+ out = run_command("bundle exec ","rake test", return_err_and_status: false, expect_failure: false, rubylib: scaffold_lib)
24
+ assert_match /0 failures/,out
25
+ assert_match /0 errors/,out
26
+ assert_match /0 skips/,out
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,52 @@
1
+ require "minitest/autorun"
2
+ require "pathname"
3
+ require "fileutils"
4
+
5
+ # Copied from https://github.com/splattael/minitest-around
6
+ # so as to avoid an explicit dependency
7
+ Minitest::Test.class_eval do
8
+ alias_method :run_without_around, :run
9
+ def run(*args)
10
+ if defined?(around)
11
+ result = nil
12
+ around { result = run_without_around(*args) }
13
+ result
14
+ else
15
+ run_without_around(*args)
16
+ end
17
+ end
18
+ end
19
+
20
+ module TestHelper
21
+ def around(&block)
22
+ Bundler.with_original_env do
23
+ root = Pathname(__FILE__).dirname / ".." / ".."
24
+ FileUtils.chdir root do
25
+ block.()
26
+ end
27
+ end
28
+ end
29
+
30
+ def run_gli(args="", return_err_and_status: false, expect_failure: false)
31
+ run_command("bin/gli",args,return_err_and_status:return_err_and_status,expect_failure:expect_failure)
32
+ end
33
+
34
+ def run_command(command,args,return_err_and_status:,expect_failure:,rubylib:nil)
35
+ command_line_invocation = "#{command} #{args}"
36
+ env = {}
37
+ if !rubylib.nil?
38
+ env["RUBYLIB"] = rubylib
39
+ end
40
+ stdout_string, stderr_string, status = Open3.capture3(env,command_line_invocation)
41
+ if expect_failure
42
+ refute_equal 0,status.exitstatus,"Expected failure for '#{command_line_invocation}' but it succeeded"
43
+ else
44
+ assert_equal 0,status.exitstatus,"Expected success for '#{command_line_invocation}' but it failed:\n#{stdout_string}\n\n#{stderr_string}\n\n"
45
+ end
46
+ if return_err_and_status
47
+ [ stdout_string, stderr_string, status ]
48
+ else
49
+ stdout_string
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,54 @@
1
+ require_relative "test_helper"
2
+
3
+ class CommandFinderTest < MiniTest::Test
4
+ include TestHelper
5
+
6
+ def setup
7
+ @app = CLIApp.new
8
+ [:status, :deployable, :some_command, :some_similar_command].each do |command|
9
+ @app.commands[command] = GLI::Command.new(:names => command)
10
+ end
11
+ end
12
+
13
+ def teardown
14
+ end
15
+
16
+ def test_unknown_command_name
17
+ assert_raises(GLI::UnknownCommand) do
18
+ GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(:unfindable_command)
19
+ end
20
+ end
21
+
22
+ def test_no_command_name_without_default
23
+ assert_raises(GLI::UnknownCommand) do
24
+ GLI::CommandFinder.new(@app.commands).find_command(nil)
25
+ end
26
+ end
27
+
28
+ def test_no_command_name_with_default
29
+ actual = GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(nil)
30
+ expected = @app.commands[:status]
31
+
32
+ assert_equal(actual, expected)
33
+ end
34
+
35
+ def test_ambigous_command
36
+ assert_raises(GLI::AmbiguousCommand) do
37
+ GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(:some)
38
+ end
39
+ end
40
+
41
+ def test_partial_name_with_autocorrect_enabled
42
+ actual = GLI::CommandFinder.new(@app.commands, :default_command => :status).find_command(:deploy)
43
+ expected = @app.commands[:deployable]
44
+
45
+ assert_equal(actual, expected)
46
+ end
47
+
48
+ def test_partial_name_with_autocorrect_disabled
49
+ assert_raises(GLI::UnknownCommand) do
50
+ GLI::CommandFinder.new(@app.commands, :default_command => :status, :autocomplete => false)
51
+ .find_command(:deploy)
52
+ end
53
+ end
54
+ end
@@ -1,7 +1,7 @@
1
- require 'test_helper'
2
- require 'tempfile'
1
+ require_relative "test_helper"
2
+ require_relative "support/fake_std_out"
3
3
 
4
- class TC_testCommand < Clean::Test::TestCase
4
+ class CommandTest < MiniTest::Test
5
5
  include TestHelper
6
6
  def setup
7
7
  @fake_stdout = FakeStdOut.new
@@ -40,8 +40,6 @@ class TC_testCommand < Clean::Test::TestCase
40
40
 
41
41
  def test_basic_command
42
42
  [false,true].each do |openstruct|
43
- end
44
- [true].each do |openstruct|
45
43
  create_app(openstruct)
46
44
  openstruct_message = openstruct ? ", with use_openstruct" : ""
47
45
  args_args = [%w(-g basic -v -c foo bar baz quux), %w(-g basic -v --configure=foo bar baz quux)]
@@ -61,6 +59,12 @@ class TC_testCommand < Clean::Test::TestCase
61
59
  end
62
60
  end
63
61
 
62
+ def test_openstruct_with_nested_commands
63
+ create_app(true)
64
+ @app.run(["top","nested"])
65
+ assert(!@error_called,"Error block should not have been called: #{@exception_caught.inspect}")
66
+ end
67
+
64
68
  def test_around_filter
65
69
  @around_block_called = false
66
70
  @app.around do |global_options, command, options, arguments, code|
@@ -432,7 +436,7 @@ class TC_testCommand < Clean::Test::TestCase
432
436
  private
433
437
 
434
438
  def assert_contained(output,regexp)
435
- assert_not_nil output.contained?(regexp),
439
+ refute_nil output.contained?(regexp),
436
440
  "Expected output to contain #{regexp.inspect}, output was:\n#{output}"
437
441
  end
438
442
 
@@ -459,9 +463,10 @@ class TC_testCommand < Clean::Test::TestCase
459
463
  @pre_called = false
460
464
  @post_called = false
461
465
  @error_called = false
466
+ @exception_caught = nil
462
467
  @app.pre { |g,c,o,a| @pre_called = true }
463
468
  @app.post { |g,c,o,a| @post_called = true }
464
- @app.on_error { |g,c,o,a| @error_called = true }
469
+ @app.on_error { |exception| @error_called = true; @exception_caught = exception }
465
470
  @glob = nil
466
471
  @verbose = nil
467
472
  @glob_verbose = nil
@@ -503,6 +508,14 @@ class TC_testCommand < Clean::Test::TestCase
503
508
  @app.command [:test_wrap] do |c|
504
509
  c.action {}
505
510
  end
511
+
512
+ @app.desc "A top-level command"
513
+ @app.command [:top] do |c|
514
+ c.desc "A nested command"
515
+ c.command [:nested] do |nested|
516
+ nested.action {}
517
+ end
518
+ end
506
519
  end
507
520
 
508
521
  end
@@ -0,0 +1,17 @@
1
+ require_relative "test_helper"
2
+
3
+ class CompoundCommandFinderTest < MiniTest::Test
4
+ include TestHelper
5
+
6
+ def test_exception_for_missing_commands
7
+ @name = "new"
8
+ @unknown_name = "create"
9
+ @existing_command = OpenStruct.new(:name => @name)
10
+ @base = OpenStruct.new( :commands => { @name => @existing_command })
11
+
12
+ @code = lambda { GLI::Commands::CompoundCommand.new(@base,{:foo => [@name,@unknown_name]}) }
13
+
14
+ ex = assert_raises(RuntimeError,&@code)
15
+ assert_match /#{Regexp.escape(@unknown_name)}/,ex.message
16
+ end
17
+ end
@@ -1,5 +1,4 @@
1
- require 'test_helper'
2
- require 'pp'
1
+ require_relative "test_helper"
3
2
 
4
3
  class String
5
4
  def blank?
@@ -19,7 +18,7 @@ class Object
19
18
  end
20
19
  end
21
20
 
22
- class TC_testDoc < Clean::Test::TestCase
21
+ class DocTest < MiniTest::Test
23
22
  include TestHelper
24
23
 
25
24
  class TestApp
@@ -112,42 +111,30 @@ class TC_testDoc < Clean::Test::TestCase
112
111
  @@counter = -1 # we pre-increment so this makes 0 first
113
112
  end
114
113
 
115
- test_that "a GLI app with documentation gets the callbacks for each element" do
116
- Given :the_test_app
117
- And :the_expected_output
118
- And {
119
- @documenter = GLI::Commands::Doc.new(@app)
120
- @listener = TestListener.new
121
- }
122
- When {
123
- @documenter.document(@listener)
124
- }
125
- Then {
126
- lines_expected = @string.split(/\n/)
127
- lines_got = @listener.to_s.split(/\n/)
128
- lines_expected.zip(lines_got).each_with_index do |(expected,got),index|
129
- assert_equal expected,got,"At index #{index}"
130
- end
131
- }
114
+ def test_app_without_docs_gets_callbacks_for_each_element
115
+ setup_test_app
116
+ construct_expected_output
117
+ @documenter = GLI::Commands::Doc.new(@app)
118
+ @listener = TestListener.new
119
+ @documenter.document(@listener)
120
+ lines_expected = @string.split(/\n/)
121
+ lines_got = @listener.to_s.split(/\n/)
122
+ lines_expected.zip(lines_got).each_with_index do |(expected,got),index|
123
+ assert_equal expected,got,"At index #{index}"
124
+ end
132
125
  end
133
126
 
134
- test_that "the doc command works as a GLI command" do
135
- Given :the_test_app
136
- And :the_expected_output
137
- And {
138
- @documenter = GLI::Commands::Doc.new(@app)
139
- @listener = TestListener.new
140
- }
141
- When {
142
- @documenter.execute({},{:format => "TC_testDoc::TestListener"},[])
143
- }
144
- Then {
145
- lines_expected = @string.split(/\n/)
146
- lines_got = TestListener.last.to_s.split(/\n/)
147
- lines_expected.zip(lines_got).each_with_index do |(expected,got),index|
148
- assert_equal expected,got,"At index #{index}"
149
- end
150
- }
127
+ def test_doc_command_works_as_GLI_command
128
+ setup_test_app
129
+ construct_expected_output
130
+ @documenter = GLI::Commands::Doc.new(@app)
131
+ @listener = TestListener.new
132
+ @documenter.execute({},{:format => "DocTest::TestListener"},[])
133
+ lines_expected = @string.split(/\n/)
134
+ lines_got = TestListener.last.to_s.split(/\n/)
135
+ lines_expected.zip(lines_got).each_with_index do |(expected,got),index|
136
+ assert_equal expected,got,"At index #{index}"
137
+ end
151
138
  end
152
139
 
153
140
  private
@@ -158,36 +145,36 @@ private
158
145
  @@counter
159
146
  end
160
147
 
161
- def the_test_app
148
+ def setup_test_app
162
149
  @app = TestApp.new
163
150
  @app.instance_eval do
164
151
  program_desc "program desc"
165
152
  program_long_desc "program long desc"
166
153
  version "1.3.4"
167
154
 
168
- TC_testDoc.flag_with_everything_specified(self)
169
- TC_testDoc.flag_with_everything_omitted(self)
170
- TC_testDoc.switch_with_everything_specified(self)
171
- TC_testDoc.switch_with_everything_omitted(self)
155
+ DocTest.flag_with_everything_specified(self)
156
+ DocTest.flag_with_everything_omitted(self)
157
+ DocTest.switch_with_everything_specified(self)
158
+ DocTest.switch_with_everything_omitted(self)
172
159
 
173
160
  desc "command desc"
174
161
  long_desc "command long desc"
175
162
  arg_name "cmd_arg_name"
176
163
  command [:command1,:com1] do |c|
177
- TC_testDoc.flag_with_everything_specified(c)
178
- TC_testDoc.flag_with_everything_omitted(c)
179
- TC_testDoc.switch_with_everything_specified(c)
180
- TC_testDoc.switch_with_everything_omitted(c)
164
+ DocTest.flag_with_everything_specified(c)
165
+ DocTest.flag_with_everything_omitted(c)
166
+ DocTest.switch_with_everything_specified(c)
167
+ DocTest.switch_with_everything_omitted(c)
181
168
 
182
169
  c.desc "subcommand desc"
183
170
  c.long_desc "subcommand long desc"
184
171
  c.arg_name "subcmd_arg_name"
185
172
  c.action { |g,o,a| }
186
173
  c.command [:sub,:subcommand] do |sub|
187
- TC_testDoc.flag_with_everything_specified(sub,:subflag)
188
- TC_testDoc.flag_with_everything_omitted(sub,:subflag2)
189
- TC_testDoc.switch_with_everything_specified(sub,:subswitch)
190
- TC_testDoc.switch_with_everything_omitted(sub,:subswitch2)
174
+ DocTest.flag_with_everything_specified(sub,:subflag)
175
+ DocTest.flag_with_everything_omitted(sub,:subflag2)
176
+ DocTest.switch_with_everything_specified(sub,:subswitch)
177
+ DocTest.switch_with_everything_omitted(sub,:subswitch2)
191
178
  sub.action { |g,o,a| }
192
179
  end
193
180
  c.command [:default] do |sub|
@@ -227,7 +214,7 @@ private
227
214
  def self.switch_with_everything_omitted(on,name=[:S,:switch2])
228
215
  on.switch name
229
216
  end
230
- def the_expected_output
217
+ def construct_expected_output
231
218
  # Oh yeah. Creating a string representing the structure of the calls.
232
219
  @string =<<EOS
233
220
  BEGIN
@@ -1,39 +1,36 @@
1
- require 'test_helper'
1
+ require_relative "test_helper"
2
2
 
3
- class TC_testFlag < Clean::Test::TestCase
3
+ class FlagTest < MiniTest::Test
4
4
  include TestHelper
5
5
 
6
6
  def test_basics_simple
7
- Given flag_with_names(:f)
8
- Then attributes_should_be_set
9
- And name_should_be(:f)
10
- And aliases_should_be(nil)
7
+ setup_for_flag_with_names(:f)
8
+ assert_attributes_set
9
+ assert_equal(:f,@cli_option.name)
10
+ assert_nil @cli_option.aliases
11
11
  end
12
12
 
13
13
  def test_basics_kinda_complex
14
- Given flag_with_names([:f])
15
- Then attributes_should_be_set
16
- And name_should_be(:f)
17
- And aliases_should_be(nil)
14
+ setup_for_flag_with_names([:f])
15
+ assert_attributes_set
16
+ assert_equal(:f,@cli_option.name)
17
+ assert_nil @cli_option.aliases
18
18
  end
19
19
 
20
20
  def test_basics_complex
21
- Given flag_with_names([:f,:file,:filename])
22
- Then attributes_should_be_set
23
- And name_should_be(:f)
24
- And aliases_should_be([:file,:filename])
25
- And {
26
- assert_equal ["-f VAL","--file VAL","--filename VAL",/foobar/,Float],@flag.arguments_for_option_parser
27
- }
21
+ setup_for_flag_with_names([:f,:file,:filename])
22
+ assert_attributes_set
23
+ assert_equal(:f,@cli_option.name)
24
+ assert_equal [:file,:filename], @cli_option.aliases
25
+ assert_equal ["-f VAL","--file VAL","--filename VAL",/foobar/,Float],@flag.arguments_for_option_parser
28
26
  end
29
27
 
30
28
  def test_flag_can_mask_its_value
31
- Given flag_with_names(:password, :mask => true)
32
- Then attributes_should_be_set(:safe_default_value => "********")
29
+ setup_for_flag_with_names(:password, :mask => true)
30
+ assert_attributes_set(:safe_default_value => "********")
33
31
  end
34
32
 
35
- def flag_with_names(names,options = {})
36
- lambda do
33
+ def setup_for_flag_with_names(names,options = {})
37
34
  @options = {
38
35
  :desc => 'Filename',
39
36
  :long_desc => 'The Filename',
@@ -45,11 +42,9 @@ class TC_testFlag < Clean::Test::TestCase
45
42
  }.merge(options)
46
43
  @flag = GLI::Flag.new(names,@options)
47
44
  @cli_option = @flag
48
- end
49
45
  end
50
46
 
51
- def attributes_should_be_set(override={})
52
- lambda {
47
+ def assert_attributes_set(override={})
53
48
  expected = @options.merge(override)
54
49
  assert_equal(expected[:desc],@flag.description)
55
50
  assert_equal(expected[:long_desc],@flag.long_description)
@@ -57,6 +52,5 @@ class TC_testFlag < Clean::Test::TestCase
57
52
  assert_equal(expected[:safe_default_value],@flag.safe_default_value)
58
53
  assert_equal(expected[:must_match],@flag.must_match)
59
54
  assert_equal(expected[:type],@flag.type)
60
- }
61
55
  end
62
56
  end