Sha256: 3e13d4fb795e46432777fab5f6e22306bb7508c63eddb0949189bb0591e55828

Contents?: true

Size: 884 Bytes

Versions: 5

Compression:

Stored size: 884 Bytes

Contents

require 'test_helper'

module ApiPi
  class TestRequests < TestCase

    def setup
      @good_url = "http://test-service.com/200.json"
      @good_header = { 'Content-Type' => 'application/json' }
      stub_request(:get, @good_url)
                  .to_return(status: 200, body: "", headers: @good_header)
    end

    def test_kernel_responds_to_get
      assert Kernel.respond_to?(:get)
    end

    def test_kernel_responds_to_set_header
      assert Kernel.respond_to?(:set_header)
    end

    def test_set_header
      set_header "User-Agent", "Api-Pi Test"
      set_header "Not-A-Field", "But-I-Work"
      assert ApiPi::HEADER.has_key?("User-Agent")
      assert ApiPi::HEADER.has_key?("Not-A-Field")
    end

    def test_dhash
      resp = Net::HTTP.get_response(URI(@good_url))
      header = resp.to_dhash
      assert header.has_key?('contenttype')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
api_pi-0.9.3 test/unit/test_requests.rb
api_pi-0.9.2 test/unit/test_requests.rb
api_pi-0.9 test/unit/test_requests.rb
api_pi-0.2.3 test/unit/test_requests.rb
api_pi-0.2.2 test/unit/test_requests.rb