curb 0.7.15 → 1.0.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.
@@ -4,10 +4,101 @@ class FooNoToS
4
4
  end
5
5
 
6
6
  class TestCurbCurlEasy < Test::Unit::TestCase
7
+ def test_global_reset
8
+ Curl.get($TEST_URL)
9
+ # in a Timeout block you should reset the thread current handle
10
+ Curl.reset
11
+ end
12
+
13
+ def test_curlopt_stderr_with_file
14
+ # does not work with Tempfile directly
15
+ path = Tempfile.new('curb_test_curlopt_stderr').path
16
+ File.open(path, 'w') do |file|
17
+ easy = Curl::Easy.new(TestServlet.url)
18
+ easy.verbose = true
19
+ easy.setopt(Curl::CURLOPT_STDERR, file)
20
+ easy.perform
21
+ end
22
+ output = File.read(path)
23
+
24
+ assert_match(/HTTP\/1\.1\ 200\ OK(?:\ )?/, output)
25
+ assert_match('Host: 127.0.0.1:9129', output)
26
+ end
27
+
28
+ def test_curlopt_stderr_with_io
29
+ path = Tempfile.new('curb_test_curlopt_stderr').path
30
+ fd = IO.sysopen(path, 'w')
31
+ io = IO.for_fd(fd)
32
+
33
+ easy = Curl::Easy.new(TestServlet.url)
34
+ easy.verbose = true
35
+ easy.setopt(Curl::CURLOPT_STDERR, io)
36
+ easy.perform
37
+
38
+
39
+ output = File.read(path)
40
+
41
+ assert_match(output, 'HTTP/1.1 200 OK')
42
+ assert_match(output, 'Host: 127.0.0.1:9129')
43
+ end
44
+
45
+ def test_curlopt_stderr_fails_with_tempdir
46
+ Tempfile.open('curb_test_curlopt_stderr') do |tempfile|
47
+ easy = Curl::Easy.new(TestServlet.url)
48
+
49
+ assert_raise(TypeError) do
50
+ easy.setopt(Curl::CURLOPT_STDERR, tempfile)
51
+ end
52
+ end
53
+ end
54
+
55
+ def test_curlopt_stderr_fails_with_stringio
56
+ stringio = StringIO.new
57
+ easy = Curl::Easy.new(TestServlet.url)
58
+
59
+ assert_raise(TypeError) do
60
+ easy.setopt(Curl::CURLOPT_STDERR, stringio)
61
+ end
62
+ end
63
+
64
+ def test_curlopt_stderr_fails_with_string
65
+ string = String.new
66
+ easy = Curl::Easy.new(TestServlet.url)
67
+
68
+ assert_raise(TypeError) do
69
+ easy.setopt(Curl::CURLOPT_STDERR, string)
70
+ end
71
+ end
72
+
73
+ def test_exception
74
+ begin
75
+ Curl.get('NOT_FOUND_URL')
76
+ rescue
77
+ assert true
78
+ rescue Exception
79
+ assert false, "We should raise StandardError"
80
+ end
81
+ end
82
+
83
+ def test_threads
84
+ t = []
85
+ 5.times do
86
+ t << Thread.new do
87
+ 5.times do
88
+ c = Curl.get($TEST_URL)
89
+ assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
90
+ assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body)
91
+ end
92
+ end
93
+ end
94
+
95
+ t.each {|x| x.join }
96
+ end
97
+
7
98
  def test_class_perform_01
8
99
  assert_instance_of Curl::Easy, c = Curl::Easy.perform($TEST_URL)
9
100
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
10
- assert_equal "", c.header_str
101
+ assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body)
11
102
  end
12
103
 
13
104
  def test_class_perform_02
@@ -15,12 +106,11 @@ class TestCurbCurlEasy < Test::Unit::TestCase
15
106
  assert_instance_of Curl::Easy, c = Curl::Easy.perform($TEST_URL) { |curl| curl.on_body { |d| data << d; d.length } }
16
107
 
17
108
  assert_nil c.body_str
18
- assert_equal "", c.header_str
19
109
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, data)
20
110
  end
21
111
 
22
112
  def test_class_perform_03
23
- assert_raise(Curl::Err::CouldntReadError) { c = Curl::Easy.perform($TEST_URL + "nonexistent") }
113
+ assert_raise(Curl::Err::CouldntReadError) { Curl::Easy.perform($TEST_URL + "nonexistent") }
24
114
  end
25
115
 
26
116
  def test_new_01
@@ -110,7 +200,6 @@ class TestCurbCurlEasy < Test::Unit::TestCase
110
200
  c = Curl::Easy.new($TEST_URL)
111
201
  assert_equal true, c.http_get
112
202
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
113
- assert_equal "", c.header_str
114
203
  end
115
204
 
116
205
  def test_get_02
@@ -122,7 +211,6 @@ class TestCurbCurlEasy < Test::Unit::TestCase
122
211
  assert_equal true, c.http_get
123
212
 
124
213
  assert_nil c.body_str
125
- assert_equal "", c.header_str
126
214
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, data)
127
215
  end
128
216
 
@@ -305,19 +393,71 @@ class TestCurbCurlEasy < Test::Unit::TestCase
305
393
  c.max_redirects = nil
306
394
  assert_nil c.max_redirects
307
395
  end
308
-
396
+
397
+ def test_timeout_with_floats
398
+ c = Curl::Easy.new($TEST_URL)
399
+
400
+ c.timeout = 1.5
401
+ assert_equal 1500, c.timeout_ms
402
+ assert_equal 1.5, c.timeout
403
+ end
404
+
405
+ def test_timeout_with_negative
406
+ c = Curl::Easy.new($TEST_URL)
407
+
408
+ c.timeout = -1.5
409
+ assert_equal 0, c.timeout
410
+ assert_equal 0, c.timeout_ms
411
+
412
+ c.timeout = -4.8
413
+ assert_equal 0, c.timeout
414
+ assert_equal 0, c.timeout_ms
415
+ end
416
+
309
417
  def test_timeout_01
310
418
  c = Curl::Easy.new($TEST_URL)
311
-
312
- assert_nil c.timeout
313
-
419
+
420
+ assert_equal 0, c.timeout
421
+
314
422
  c.timeout = 3
315
423
  assert_equal 3, c.timeout
316
-
317
- c.timeout = nil
318
- assert_nil c.timeout
424
+
425
+ c.timeout = 0
426
+ assert_equal 0, c.timeout
319
427
  end
320
-
428
+
429
+ def test_timeout_ms_01
430
+ c = Curl::Easy.new($TEST_URL)
431
+
432
+ assert_equal 0, c.timeout_ms
433
+
434
+ c.timeout_ms = 100
435
+ assert_equal 100, c.timeout_ms
436
+
437
+ c.timeout_ms = nil
438
+ assert_equal 0, c.timeout_ms
439
+ end
440
+
441
+ def test_timeout_ms_with_floats
442
+ c = Curl::Easy.new($TEST_URL)
443
+
444
+ c.timeout_ms = 55.5
445
+ assert_equal 55, c.timeout_ms
446
+ assert_equal 0.055, c.timeout
447
+ end
448
+
449
+ def test_timeout_ms_with_negative
450
+ c = Curl::Easy.new($TEST_URL)
451
+
452
+ c.timeout_ms = -1.5
453
+ assert_equal 0, c.timeout
454
+ assert_equal 0, c.timeout_ms
455
+
456
+ c.timeout_ms = -4.8
457
+ assert_equal 0, c.timeout
458
+ assert_equal 0, c.timeout_ms
459
+ end
460
+
321
461
  def test_connect_timeout_01
322
462
  c = Curl::Easy.new($TEST_URL)
323
463
 
@@ -329,7 +469,19 @@ class TestCurbCurlEasy < Test::Unit::TestCase
329
469
  c.connect_timeout = nil
330
470
  assert_nil c.connect_timeout
331
471
  end
332
-
472
+
473
+ def test_connect_timeout_ms_01
474
+ c = Curl::Easy.new($TEST_URL)
475
+
476
+ assert_nil c.connect_timeout_ms
477
+
478
+ c.connect_timeout_ms = 100
479
+ assert_equal 100, c.connect_timeout_ms
480
+
481
+ c.connect_timeout_ms = nil
482
+ assert_nil c.connect_timeout_ms
483
+ end
484
+
333
485
  def test_ftp_response_timeout_01
334
486
  c = Curl::Easy.new($TEST_URL)
335
487
 
@@ -461,7 +613,8 @@ class TestCurbCurlEasy < Test::Unit::TestCase
461
613
  def test_ssl_verify_host
462
614
  c = Curl::Easy.new
463
615
  assert c.ssl_verify_host?
464
- assert !c.ssl_verify_host = false
616
+ c.ssl_verify_host = 0
617
+ c.ssl_verify_host = false
465
618
  assert !c.ssl_verify_host?
466
619
  end
467
620
 
@@ -507,6 +660,17 @@ class TestCurbCurlEasy < Test::Unit::TestCase
507
660
  assert c.ignore_content_length?
508
661
  end
509
662
 
663
+ def test_resolve_mode
664
+ c = Curl::Easy.new
665
+ assert_equal :auto, c.resolve_mode
666
+ c.resolve_mode = :ipv4
667
+ assert_equal :ipv4, c.resolve_mode
668
+ c.resolve_mode = :ipv6
669
+ assert_equal :ipv6, c.resolve_mode
670
+
671
+ assert_raises(ArgumentError) { c.resolve_mode = :bad }
672
+ end
673
+
510
674
  def test_enable_cookies
511
675
  c = Curl::Easy.new
512
676
  assert !c.enable_cookies?
@@ -535,6 +699,15 @@ class TestCurbCurlEasy < Test::Unit::TestCase
535
699
  assert_equal "some.file", c.cookiejar
536
700
  end
537
701
 
702
+ def test_cookielist
703
+ c = Curl::Easy.new TestServlet.url
704
+ c.enable_cookies = true
705
+ c.post_body = URI.encode_www_form('c' => 'somename=somevalue')
706
+ assert_nil c.cookielist
707
+ c.perform
708
+ assert_match(/somevalue/, c.cookielist.join(''))
709
+ end
710
+
538
711
  def test_on_success
539
712
  curl = Curl::Easy.new($TEST_URL)
540
713
  on_success_called = false
@@ -549,13 +722,34 @@ class TestCurbCurlEasy < Test::Unit::TestCase
549
722
  end
550
723
 
551
724
  def test_on_success_with_on_failure
552
- curl = Curl::Easy.new("#{$TEST_URL.gsub(/file:\/\//,'')}/not_here")
725
+ curl = Curl::Easy.new(TestServlet.url + '/error')
553
726
  on_failure_called = false
554
727
  curl.on_success {|c| } # make sure we get the failure call even though this handler is defined
555
728
  curl.on_failure {|c,code| on_failure_called = true }
556
729
  curl.perform
730
+ assert_equal 500, curl.response_code
557
731
  assert on_failure_called, "Failure handler not called"
558
732
  end
733
+
734
+ def test_on_success_with_on_missing
735
+ curl = Curl::Easy.new(TestServlet.url + '/not_here')
736
+ on_missing_called = false
737
+ curl.on_success {|c| } # make sure we get the missing call even though this handler is defined
738
+ curl.on_missing {|c,code| on_missing_called = true }
739
+ curl.perform
740
+ assert_equal 404, curl.response_code
741
+ assert on_missing_called, "Missing handler not called"
742
+ end
743
+
744
+ def test_on_success_with_on_redirect
745
+ curl = Curl::Easy.new(TestServlet.url + '/redirect')
746
+ on_redirect_called = false
747
+ curl.on_success {|c| } # make sure we get the redirect call even though this handler is defined
748
+ curl.on_redirect {|c,code| on_redirect_called = true }
749
+ curl.perform
750
+ assert_equal 302, curl.response_code
751
+ assert on_redirect_called, "Redirect handler not called"
752
+ end
559
753
 
560
754
  def test_get_remote
561
755
  curl = Curl::Easy.new(TestServlet.url)
@@ -572,15 +766,35 @@ class TestCurbCurlEasy < Test::Unit::TestCase
572
766
  def test_post_remote_is_easy_handle
573
767
  # see: http://pastie.org/560852 and
574
768
  # http://groups.google.com/group/curb---ruby-libcurl-bindings/browse_thread/thread/216bb2d9b037f347?hl=en
575
- [:post, :get,:head,:delete].each do |method|
576
- count = 0
577
- curl = Curl::Easy.send("http_#{method}", TestServlet.url) do|c|
578
- count += 1
579
- assert_equal Curl::Easy, c.class
769
+ [:post, :get, :head, :delete].each do |method|
770
+ retries = 0
771
+ begin
772
+ count = 0
773
+ Curl::Easy.send("http_#{method}", TestServlet.url) do|c|
774
+ count += 1
775
+ assert_equal Curl::Easy, c.class
776
+ end
777
+ assert_equal 1, count, "For request method: #{method.to_s.upcase}"
778
+ rescue Curl::Err::HostResolutionError => e # travis-ci.org fails to resolve... try again?
779
+ retries+=1
780
+ retry if retries < 3
781
+ raise e
580
782
  end
581
- assert_equal 1, count, "For request method: #{method.to_s.upcase}"
582
783
  end
583
784
  end
785
+
786
+ # see: https://github.com/rvanlieshout/curb/commit/8bcdefddc0162484681ebd1a92d52a642666a445
787
+ def test_post_multipart_array_remote
788
+ curl = Curl::Easy.new(TestServlet.url)
789
+ curl.multipart_form_post = true
790
+ fields = [
791
+ Curl::PostField.file('foo', File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown'))),
792
+ Curl::PostField.file('bar', File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown')))
793
+ ]
794
+ curl.http_post(fields)
795
+ assert_match(/HTTP POST file upload/, curl.body_str)
796
+ assert_match(/Content-Disposition: form-data/, curl.body_str)
797
+ end
584
798
 
585
799
  def test_post_with_body_remote
586
800
  curl = Curl::Easy.new(TestServlet.url)
@@ -603,10 +817,10 @@ class TestCurbCurlEasy < Test::Unit::TestCase
603
817
  def test_post_multipart_file_remote
604
818
  curl = Curl::Easy.new(TestServlet.url)
605
819
  curl.multipart_form_post = true
606
- pf = Curl::PostField.file('readme', File.expand_path(File.join(File.dirname(__FILE__),'..','README')))
820
+ pf = Curl::PostField.file('readme', File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown')))
607
821
  curl.http_post(pf)
608
- assert_match /HTTP POST file upload/, curl.body_str
609
- assert_match /Content-Disposition: form-data/, curl.body_str
822
+ assert_match(/HTTP POST file upload/, curl.body_str)
823
+ assert_match(/Content-Disposition: form-data/, curl.body_str)
610
824
  end
611
825
 
612
826
  def test_delete_remote
@@ -628,7 +842,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
628
842
  redirect = curl.header_str.match(/Location: (.*)/)
629
843
 
630
844
  assert_equal '', curl.body_str
631
- assert_match '/nonexistent', redirect[1]
845
+ assert_match('/nonexistent', redirect[1])
632
846
  end
633
847
 
634
848
  def test_head_accessor
@@ -639,7 +853,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
639
853
  redirect = curl.header_str.match(/Location: (.*)/)
640
854
 
641
855
  assert_equal '', curl.body_str
642
- assert_match '/nonexistent', redirect[1]
856
+ assert_match('/nonexistent', redirect[1])
643
857
  curl.head = false
644
858
  curl.perform
645
859
  assert_equal 'GET', curl.body_str
@@ -649,9 +863,11 @@ class TestCurbCurlEasy < Test::Unit::TestCase
649
863
  curl = Curl::Easy.new(TestServlet.url)
650
864
  curl.headers['Content-Type'] = 'application/json'
651
865
  assert curl.http_put("message")
652
- assert_match /^PUT/, curl.body_str
653
- assert_match /message$/, curl.body_str
654
- assert_match /application\/json/, curl.header_str
866
+ assert_match(/^PUT/, curl.body_str)
867
+ assert_match(/message$/, curl.body_str)
868
+ assert_match(/message$/, curl.body)
869
+ assert_match(/application\/json/, curl.header_str)
870
+ assert_match(/application\/json/, curl.head)
655
871
  end
656
872
 
657
873
  def test_put_data
@@ -660,8 +876,19 @@ class TestCurbCurlEasy < Test::Unit::TestCase
660
876
 
661
877
  curl.perform
662
878
 
663
- assert_match /^PUT/, curl.body_str
664
- assert_match /message$/, curl.body_str
879
+ assert_match(/^PUT/, curl.body_str)
880
+ assert_match(/message$/, curl.body_str)
881
+ end
882
+
883
+ # https://github.com/taf2/curb/issues/101
884
+ def test_put_data_null_bytes
885
+ curl = Curl::Easy.new(TestServlet.url)
886
+ curl.put_data = "a\0b"
887
+
888
+ curl.perform
889
+
890
+ assert_match(/^PUT/, curl.body_str)
891
+ assert_match("a\0b", curl.body_str)
665
892
  end
666
893
 
667
894
  def test_put_nil_data_no_crash
@@ -673,10 +900,10 @@ class TestCurbCurlEasy < Test::Unit::TestCase
673
900
 
674
901
  def test_put_remote_file
675
902
  curl = Curl::Easy.new(TestServlet.url)
676
- File.open(__FILE__,'r') do|f|
903
+ File.open(__FILE__,'rb') do|f|
677
904
  assert curl.http_put(f)
678
905
  end
679
- assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str
906
+ assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str.tr("\r", '')
680
907
  end
681
908
 
682
909
  def test_put_class_method
@@ -686,7 +913,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
686
913
  assert_equal Curl::Easy, c.class
687
914
  end
688
915
  assert_equal 1, count
689
- assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str
916
+ assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str.tr("\r", '')
690
917
  end
691
918
 
692
919
  # Generate a self-signed cert with
@@ -695,13 +922,15 @@ class TestCurbCurlEasy < Test::Unit::TestCase
695
922
  def test_cert
696
923
  curl = Curl::Easy.new(TestServlet.url)
697
924
  curl.cert= File.join(File.dirname(__FILE__),"cert.pem")
698
- assert_match /cert.pem$/,curl.cert
925
+ assert_match(/cert.pem$/,curl.cert)
699
926
  end
700
927
 
701
928
  def test_cert_with_password
702
929
  curl = Curl::Easy.new(TestServlet.url)
703
- curl.cert= File.join(File.dirname(__FILE__),"cert.pem:password")
704
- assert_match /cert.pem$/,curl.cert
930
+ path = File.join(File.dirname(__FILE__),"cert.pem")
931
+ curl.certpassword = 'password'
932
+ curl.cert = path
933
+ assert_match(/cert.pem$/,curl.cert)
705
934
  end
706
935
 
707
936
  def test_cert_type
@@ -722,7 +951,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
722
951
  def test_ca_cert
723
952
  curl = Curl::Easy.new(TestServlet.url)
724
953
  curl.cacert= File.join(File.dirname(__FILE__),"cacert.pem")
725
- assert_match /cacert.pem$/, curl.cacert
954
+ assert_match(/cacert.pem$/, curl.cacert)
726
955
  end
727
956
 
728
957
  def test_user_agent
@@ -769,7 +998,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
769
998
  end
770
999
 
771
1000
  def test_post_streaming
772
- readme = File.expand_path(File.join(File.dirname(__FILE__),'..','README'))
1001
+ readme = File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown'))
773
1002
 
774
1003
  pf = Curl::PostField.file("filename", readme)
775
1004
 
@@ -780,7 +1009,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
780
1009
  easy.http_post(pf)
781
1010
 
782
1011
  assert_not_equal(0,easy.body_str.size)
783
- assert_equal(easy.body_str,File.read(readme))
1012
+ assert_equal(easy.body_str.tr("\r", ''), File.read(readme))
784
1013
  end
785
1014
 
786
1015
 
@@ -876,8 +1105,8 @@ class TestCurbCurlEasy < Test::Unit::TestCase
876
1105
  curl.headers['Accept'] = '*/*'
877
1106
  curl.headers['Authorization'] = 'Foo Bar Biz Baz'
878
1107
  curl.http_put(rd)
879
- assert_match /^PUT/, curl.body_str
880
- assert_match /hello$/, curl.body_str
1108
+ assert_match(/^PUT/, curl.body_str)
1109
+ assert_match(/hello$/, curl.body_str)
881
1110
  curl.header_str
882
1111
  curl.body_str
883
1112
  end
@@ -888,6 +1117,61 @@ class TestCurbCurlEasy < Test::Unit::TestCase
888
1117
 
889
1118
  end
890
1119
 
1120
+ def test_get_set_multi_on_easy
1121
+ easy = Curl::Easy.new
1122
+ assert_nil easy.multi
1123
+ multi = Curl::Multi.new
1124
+ easy.multi = multi
1125
+ assert_not_nil easy.multi
1126
+ assert_equal multi, easy.multi
1127
+ end
1128
+
1129
+ def test_raise_on_progress
1130
+ c = Curl::Easy.new($TEST_URL)
1131
+ c.on_progress {|w,x,y,z| raise "error" }
1132
+ c.perform
1133
+ rescue => e
1134
+ assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
1135
+ c.close
1136
+ end
1137
+
1138
+ def test_raise_on_success
1139
+ c = Curl::Easy.new($TEST_URL)
1140
+ c.on_success {|x| raise "error" }
1141
+ c.perform
1142
+ rescue => e
1143
+ assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
1144
+ c.close
1145
+ end
1146
+
1147
+ def test_raise_on_debug
1148
+ c = Curl::Easy.new($TEST_URL)
1149
+ c.on_debug { raise "error" }
1150
+ c.perform
1151
+ assert true, "raise in on debug has no effect"
1152
+ end
1153
+
1154
+ def test_status_codes
1155
+ curl = Curl::Easy.new(TestServlet.url)
1156
+ curl.perform
1157
+ assert_equal '200 OK', curl.status
1158
+ end
1159
+
1160
+ def test_close_in_on_callbacks
1161
+ curl = Curl::Easy.new(TestServlet.url)
1162
+ curl.on_body {|d| curl.close; d.size }
1163
+ assert_raises RuntimeError do
1164
+ curl.perform
1165
+ end
1166
+ end
1167
+
1168
+ def test_set_unsupported_options
1169
+ curl = Curl::Easy.new
1170
+ assert_raises TypeError do
1171
+ curl.set(99999, 1)
1172
+ end
1173
+ end
1174
+
891
1175
  include TestServerMethods
892
1176
 
893
1177
  def setup
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
+
3
+ class TestCurbCurlEasyResolve < Test::Unit::TestCase
4
+ def setup
5
+ @easy = Curl::Easy.new
6
+ end
7
+
8
+ def test_resolve
9
+ @easy.resolve = [ "example.com:80:127.0.0.1" ]
10
+ assert_equal @easy.resolve, [ "example.com:80:127.0.0.1" ]
11
+ end
12
+
13
+ def test_empty_resolve
14
+ assert_equal @easy.resolve, nil
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
+
3
+ class TestCurbCurlEasySetOpt < Test::Unit::TestCase
4
+ def setup
5
+ @easy = Curl::Easy.new
6
+ end
7
+
8
+ def test_opt_verbose
9
+ @easy.set :verbose, true
10
+ assert @easy.verbose?
11
+ end
12
+
13
+ def test_opt_header
14
+ @easy.set :header, true
15
+ end
16
+
17
+ def test_opt_noprogress
18
+ @easy.set :noprogress, true
19
+ end
20
+
21
+ def test_opt_nosignal
22
+ @easy.set :nosignal, true
23
+ end
24
+
25
+ def test_opt_url
26
+ url = "http://google.com/"
27
+ @easy.set :url, url
28
+ assert_equal url, @easy.url
29
+ end
30
+
31
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
+
3
+ class TestCurbCurlMaxFileSize < Test::Unit::TestCase
4
+ def setup
5
+ @easy = Curl::Easy.new
6
+ end
7
+
8
+ def test_maxfilesize
9
+ @easy.set(Curl::CURLOPT_MAXFILESIZE, 5000000)
10
+ end
11
+
12
+ end