Permalink
Browse files

Use Net::HTTP instead of curl

There was some problem with command line parsing with a special character.
  • Loading branch information...
1 parent 88a8af9 commit bb22be301a783b2e2ab58f7904231ffd8211766c @sikachu sikachu committed Dec 12, 2011
Showing with 19 additions and 5 deletions.
  1. +14 −0 test/helper.rb
  2. +5 −5 test/storage/s3_live_test.rb
View
@@ -161,3 +161,17 @@ def with_exitstatus_returning(code)
def fixture_file(filename)
File.join(File.dirname(__FILE__), 'fixtures', filename)
end
+
+def assert_success_response(url)
+ Net::HTTP.get_response(URI.parse(url)) do |response|
+ assert_equal "200", response.code,
+ "Expected HTTP response code 200, got #{response.code}"
+ end
+end
+
+def assert_not_found_response(url)
+ Net::HTTP.get_response(URI.parse(url)) do |response|
+ assert_equal "404", response.code,
+ "Expected HTTP response code 404, got #{response.code}"
+ end
+end
@@ -91,13 +91,13 @@ class S3LiveTest < Test::Unit::TestCase
end
should "be accessible" do
- assert_match /200 OK/, `curl -I #{@dummy.avatar.url}`
+ assert_success_response @dummy.avatar.url
end
should "be destoryable" do
url = @dummy.avatar.url
@dummy.destroy
- assert_match /404 Not Found/, `curl -I #{url}`
+ assert_not_found_response url
end
end
@@ -125,17 +125,17 @@ class S3LiveTest < Test::Unit::TestCase
end
should "be accessible" do
- assert_match /200 OK/, `curl -I "#{@dummy.avatar.url}"`
+ assert_success_response @dummy.avatar.url
end
should "be accessible with an expiring url" do
- assert_match /200 OK/, `curl -I "#{@dummy.avatar.expiring_url}"`
+ assert_success_response @dummy.avatar.expiring_url
end
should "be destroyable" do
url = @dummy.avatar.url
@dummy.destroy
- assert_match /404 Not Found/, `curl -I "#{url}"`
+ assert_not_found_response url
end
end
end

0 comments on commit bb22be3

Please sign in to comment.