Skip to content

Commit

Permalink
Use Net::HTTP instead of curl
Browse files Browse the repository at this point in the history
There was some problem with command line parsing with a special character.
  • Loading branch information
sikachu committed Dec 12, 2011
1 parent 88a8af9 commit bb22be3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 14 additions & 0 deletions test/helper.rb
Expand Up @@ -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
10 changes: 5 additions & 5 deletions test/storage/s3_live_test.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb22be3

Please sign in to comment.