Sha256: d96e9d3179c3af9a29927f76b3a5e1e8ceeee9ab6ce4a5884c0954f57c6ef4cd

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8

require_relative 'test_helper'
require 'vcr'

VCR.configure do |c|
  c.cassette_library_dir = "#{File.dirname(__FILE__)}/fixtures-vcr"
  c.hook_into :webmock
end

class HttpTest < Test::Unit::TestCase
  def test_get_with_redirection
    VCR.use_cassette('http_test') do
      google = Http.get("http://google.de")
      assert google.starts_with?("<!doctype html>")
    end
  end

  def test_get_body_and_headers
    VCR.use_cassette('http_test') do
      body, headers = Http.get("http://google.de", 0)
      assert body.starts_with?("<!doctype html>")
      assert_equal "UTF-8", body.encoding.name
    end
  end

  def test_xml_url
    VCR.use_cassette('http_test', :record => :new_episodes) do
      body, headers = Http.get("http://nowhere.test/9162.xml", 0)
      assert body =~ /Tänzerin/, "Encoding should accept UTF-8 umlauts"
      assert_equal "UTF-8", body.encoding.name
    end
  end

  def test_get_binaty
    VCR.use_cassette('http_test', :record => :new_episodes) do
      body, headers = Http.get_binary("http://nowhere.test/9162.xml", 0)
      assert_equal "ASCII-8BIT", body.encoding.name
    end
  end

  def test_get_charset_from_header
    VCR.use_cassette('http_test', :record => :new_episodes) do
      body = Http.get("http://www.livegigs.de/berlin/termine-babylon_mitte-14264", 0)
      assert(body =~ /präsentiert/)
    end
  end

  def test_uses_iri
    VCR.use_cassette('http_test', :record => :new_episodes) do
      body = Http.get("http://www.livegigs.de/berlin/termine-die_wühlmäuse_am_theo-27150", 0)
      assert(body =~ /präsentiert/)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
radiospieler-2014.11.28 test/http_test.rb
radiospieler-2013.04.01 test/http_test.rb
radiospieler-2012.09.13 test/http_test.rb
radiospieler-0.3.12 test/http_test.rb