Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 117 lines (100 sloc) 2.848 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
48 in_environment('RAKE_COLUMNS' => '1234') do
49 assert_equal 1234, app.terminal_width
50 end
51 end
52
53 def test_terminal_width_using_stty
54 app = Rake::Application.new
55 flexmock(app,
56 :unix? => true,
57 :dynamic_width_stty => 1235,
58 :dynamic_width_tput => 0)
59 in_environment('RAKE_COLUMNS' => nil) do
60 assert_equal 1235, app.terminal_width
61 end
62 end
63
64 def test_terminal_width_using_tput
65 app = Rake::Application.new
66 flexmock(app,
67 :unix? => true,
68 :dynamic_width_stty => 0,
69 :dynamic_width_tput => 1236)
70 in_environment('RAKE_COLUMNS' => nil) do
71 assert_equal 1236, app.terminal_width
72 end
73 end
74
75 def test_terminal_width_using_hardcoded_80
76 app = Rake::Application.new
77 flexmock(app, :unix? => false)
78 in_environment('RAKE_COLUMNS' => nil) do
79 assert_equal 80, app.terminal_width
80 end
81 end
82
83 def test_terminal_width_with_failure
84 app = Rake::Application.new
85 flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
86 in_environment('RAKE_COLUMNS' => nil) do
87 assert_equal 80, app.terminal_width
88 end
89 end
90
91 def test_no_rakeopt
92 in_environment do
93 ARGV << '--trace'
94 app = Rake::Application.new
95 app.init
96 assert !app.options.silent
97 end
98 end
99
100 def test_rakeopt_with_blank_options
101 in_environment("RAKEOPT" => "") do
102 ARGV << '--trace'
103 app = Rake::Application.new
104 app.init
105 assert !app.options.silent
106 end
107 end
108
109 def test_rakeopt_with_silent_options
110 in_environment("RAKEOPT" => "-s") do
111 app = Rake::Application.new
112 app.init
113 assert app.options.silent
114 end
115 end
116 end
Something went wrong with that request. Please try again.