Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 104 lines (80 sloc) 2.337 kb
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
1 require File.expand_path('../helper', __FILE__)
2
3 class TestRakeTaskArgumentParsing < Rake::TestCase
4 def setup
5 super
6
7 @app = Rake::Application.new
8 end
9
10 def test_name_only
11 name, args = @app.parse_task_string("name")
12 assert_equal "name", name
13 assert_equal [], args
14 end
15
16 def test_empty_args
17 name, args = @app.parse_task_string("name[]")
18 assert_equal "name", name
19 assert_equal [], args
20 end
21
22 def test_one_argument
23 name, args = @app.parse_task_string("name[one]")
24 assert_equal "name", name
25 assert_equal ["one"], args
26 end
27
28 def test_two_arguments
29 name, args = @app.parse_task_string("name[one,two]")
30 assert_equal "name", name
31 assert_equal ["one", "two"], args
32 end
33
34 def test_can_handle_spaces_between_args
35 name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
36 assert_equal "name", name
37 assert_equal ["one", "two", "three", "four"], args
38 end
39
40 def test_keeps_embedded_spaces
41 name, args = @app.parse_task_string("name[a one ana, two]")
42 assert_equal "name", name
43 assert_equal ["a one ana", "two"], args
44 end
45
46 def test_terminal_width_using_env
47 app = Rake::Application.new
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
48 app.terminal_columns = 1234
49
50 assert_equal 1234, app.terminal_width
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
51 end
52
53 def test_terminal_width_using_stty
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
54 def @app.unix?() true end
55 def @app.dynamic_width_stty() 1235 end
56 def @app.dynamic_width_tput() 0 end
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
57
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
58 assert_equal 1235, @app.terminal_width
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
59 end
60
61 def test_terminal_width_using_tput
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
62 def @app.unix?() true end
63 def @app.dynamic_width_stty() 0 end
64 def @app.dynamic_width_tput() 1236 end
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
65
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
66 assert_equal 1236, @app.terminal_width
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
67 end
68
69 def test_terminal_width_using_hardcoded_80
13d9ef6 @drbrain hardcoded 80 is used when app.unix? is false. Ruby r32642 by naruse
drbrain authored
70 def @app.unix?() false end
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
71
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
72 assert_equal 80, @app.terminal_width
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
73 end
74
75 def test_terminal_width_with_failure
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
76 def @app.unix?() raise end
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
77
928e0a2 @drbrain Remove requirement of flexmock per Ruby bug #4987
drbrain authored
78 assert_equal 80, @app.terminal_width
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
79 end
80
81 def test_no_rakeopt
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
82 ARGV << '--trace'
83 app = Rake::Application.new
84 app.init
85 assert !app.options.silent
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
86 end
87
88 def test_rakeopt_with_blank_options
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
89 ARGV << '--trace'
90 app = Rake::Application.new
91 app.init
92 assert !app.options.silent
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
93 end
94
95 def test_rakeopt_with_silent_options
a119d1b @drbrain Remove in_environment from test/test_rake_task_argument_parsing.rb
drbrain authored
96 ENV['RAKEOPT'] = '-s'
97 app = Rake::Application.new
98
99 app.init
100
101 assert app.options.silent
2d2859e @drbrain Break multi-testcase files into single-testcase files for autotest
drbrain authored
102 end
103 end
Something went wrong with that request. Please try again.