@@ -7,21 +7,22 @@ def setup
7
7
end
8
8
9
9
should "take a command and parameters and produce a shell command for bash" do
10
- cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" )
10
+ cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" , :swallow_stderr => false )
11
11
assert_equal "convert a.jpg b.png" , cmd . command
12
12
end
13
13
14
14
should "be able to set a path and produce commands with that path" do
15
15
Paperclip ::CommandLine . path = "/opt/bin"
16
- cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" )
16
+ cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" , :swallow_stderr => false )
17
17
assert_equal "/opt/bin/convert a.jpg b.png" , cmd . command
18
18
end
19
19
20
20
should "be able to interpolate quoted variables into the parameters" do
21
21
cmd = Paperclip ::CommandLine . new ( "convert" ,
22
22
":one :{two}" ,
23
23
:one => "a.jpg" ,
24
- :two => "b.png" )
24
+ :two => "b.png" ,
25
+ :swallow_stderr => false )
25
26
assert_equal "convert 'a.jpg' 'b.png'" , cmd . command
26
27
end
27
28
@@ -30,15 +31,17 @@ def setup
30
31
cmd = Paperclip ::CommandLine . new ( "convert" ,
31
32
":one :{two}" ,
32
33
:one => "a.jpg" ,
33
- :two => "b.png" )
34
+ :two => "b.png" ,
35
+ :swallow_stderr => false )
34
36
assert_equal 'convert "a.jpg" "b.png"' , cmd . command
35
37
end
36
38
37
39
should "be able to quote and interpolate dangerous variables" do
38
40
cmd = Paperclip ::CommandLine . new ( "convert" ,
39
41
":one :two" ,
40
42
:one => "`rm -rf`.jpg" ,
41
- :two => "ha'ha.png" )
43
+ :two => "ha'ha.png" ,
44
+ :swallow_stderr => false )
42
45
assert_equal "convert '`rm -rf`.jpg' 'ha'\\ ''ha.png'" , cmd . command
43
46
end
44
47
@@ -47,7 +50,8 @@ def setup
47
50
cmd = Paperclip ::CommandLine . new ( "convert" ,
48
51
":one :two" ,
49
52
:one => "`rm -rf`.jpg" ,
50
- :two => "ha'ha.png" )
53
+ :two => "ha'ha.png" ,
54
+ :swallow_stderr => false )
51
55
assert_equal %{convert "`rm -rf`.jpg" "ha'ha.png"} , cmd . command
52
56
end
53
57
@@ -80,15 +84,15 @@ def setup
80
84
end
81
85
82
86
should "run the #command it's given and return the output" do
83
- cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" )
87
+ cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" , :swallow_stderr => false )
84
88
cmd . class . stubs ( :"`" ) . with ( "convert a.jpg b.png" ) . returns ( :correct_value )
85
89
with_exitstatus_returning ( 0 ) do
86
90
assert_equal :correct_value , cmd . run
87
91
end
88
92
end
89
93
90
94
should "raise a PaperclipCommandLineError if the result code isn't expected" do
91
- cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" )
95
+ cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" , :swallow_stderr => false )
92
96
cmd . class . stubs ( :"`" ) . with ( "convert a.jpg b.png" ) . returns ( :correct_value )
93
97
with_exitstatus_returning ( 1 ) do
94
98
assert_raises ( Paperclip ::PaperclipCommandLineError ) do
@@ -100,7 +104,8 @@ def setup
100
104
should "not raise a PaperclipCommandLineError if the result code is expected" do
101
105
cmd = Paperclip ::CommandLine . new ( "convert" ,
102
106
"a.jpg b.png" ,
103
- :expected_outcodes => [ 0 , 1 ] )
107
+ :expected_outcodes => [ 0 , 1 ] ,
108
+ :swallow_stderr => false )
104
109
cmd . class . stubs ( :"`" ) . with ( "convert a.jpg b.png" ) . returns ( :correct_value )
105
110
with_exitstatus_returning ( 1 ) do
106
111
assert_nothing_raised do
@@ -110,7 +115,7 @@ def setup
110
115
end
111
116
112
117
should "log the command" do
113
- cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" )
118
+ cmd = Paperclip ::CommandLine . new ( "convert" , "a.jpg b.png" , :swallow_stderr => false )
114
119
cmd . class . stubs ( :'`' )
115
120
Paperclip . expects ( :log ) . with ( "convert a.jpg b.png" )
116
121
cmd . run
0 commit comments