Skip to content
This repository
Browse code

Testing that invalid options errors are printed.

  • Loading branch information...
commit c7a92d53e57c585c1f6eea00513b4ad233c5315b 1 parent 652b3f4
Jim Weirich authored
4 CHANGES
@@ -7,11 +7,11 @@
7 7
8 8 * Split rake.rb into individual files.
9 9
  10 +* Support for the --where (-W) flag for showing where a task is defined.
  11 +
10 12 * Fixed quoting in test task
11 13 (http://onestepback.org/redmine/issues/show/44)
12 14
13   -* Support for the --where (-W) flag for showing where a task is defined.
14   -
15 15 == Version 0.8.7
16 16
17 17 * Fixed EXEEXT for JRuby on windows.
2  lib/rake/application.rb
@@ -127,7 +127,7 @@ def standard_exception_handling
127 127 # Exit silently with current status
128 128 raise
129 129 rescue OptionParser::InvalidOption => ex
130   - # Exit silently
  130 + $stderr.puts ex.message
131 131 exit(false)
132 132 rescue Exception => ex
133 133 # Exit with error message
9 test/functional/session_based_tests.rb
@@ -23,7 +23,7 @@ def initialize(*args)
23 23 end
24 24 end
25 25
26   -class FunctionalTest < Test::Unit::TestCase
  26 +class SessionBasedTests < Test::Unit::TestCase
27 27 include InEnvironment
28 28 include TestMethods
29 29
@@ -156,6 +156,13 @@ def test_nosearch_without_rakefile_and_no_system_fails
156 156 assert_match %r{^No Rakefile found}, @err
157 157 end
158 158
  159 + def test_invalid_command_line_options
  160 + in_environment("PWD" => "test/data/default") do
  161 + rake "--bad-options"
  162 + end
  163 + assert_match %r{invalid +option}i, @err
  164 + end
  165 +
159 166 def test_dry_run
160 167 in_environment("PWD" => "test/data/default") do rake "-n", "other" end
161 168 assert_match %r{Execute \(dry run\) default}, @out
3  test/lib/application_test.rb
@@ -538,7 +538,7 @@ def test_classic_namespace
538 538 end
539 539
540 540 def test_bad_option
541   - capture_stderr do
  541 + error_output = capture_stderr do
542 542 ex = assert_exception(OptionParser::InvalidOption) do
543 543 flags('--bad-option')
544 544 end
@@ -549,6 +549,7 @@ def test_bad_option
549 549 assert_match(/--bad-option/, ex.message)
550 550 end
551 551 end
  552 + assert_equal '', error_output
552 553 end
553 554
554 555 def test_task_collection

0 comments on commit c7a92d5

Please sign in to comment.
Something went wrong with that request. Please try again.