Sha256: c87597669f89cb81a95728465199086e7a8e96c169b71e7d60995992df8dbc3a

Contents?: true

Size: 1.26 KB

Versions: 16

Compression:

Stored size: 1.26 KB

Contents

require 'test_helper'
require 'roar/representer/transport/net_http'

class NetHTTPTransportTest < MiniTest::Spec
  describe "Transport" do
    let(:url) { "http://roar.example.com/method" }
    let(:body) { "booty" }
    let(:as) { "application/xml" }
    before do
      @transport = Roar::Representer::Transport::NetHTTP.new
    end

    it "#get_uri returns response" do
      @transport.get_uri(url, as).must_match_net_response :get, url, as
    end

    it "#post_uri returns response" do
      @transport.post_uri(url, body, as).must_match_net_response :post, url, as, body
    end

    it "#put_uri returns response" do
      @transport.put_uri(url, body, as).must_match_net_response :put, url, as, body
    end

    it "#delete_uri returns response" do
      @transport.delete_uri(url, as).must_match_net_response :delete, url, as
    end

    it "#patch_uri returns response" do
      @transport.patch_uri(url, body, as).must_match_net_response :patch, url, as, body
    end
  end
end

module MiniTest::Assertions

  def assert_net_response(type, response, url, as, body = nil)
    # TODO: Assert headers
    assert_equal "<method>#{type}#{(' - ' + body) if body}</method>", response.body
  end

end

Net::HTTPOK.infect_an_assertion :assert_net_response, :must_match_net_response

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
roar-0.12.0 test/net_http_transport_test.rb
roar-0.11.19 test/net_http_transport_test.rb
roar-0.11.18 test/net_http_transport_test.rb
roar-0.11.17 test/net_http_transport_test.rb
roar-0.11.16 test/net_http_transport_test.rb
roar-0.11.15 test/net_http_transport_test.rb
roar-0.11.14 test/net_http_transport_test.rb
roar-0.11.13 test/net_http_transport_test.rb
roar-0.11.12 test/net_http_transport_test.rb
roar-0.11.11 test/net_http_transport_test.rb
roar-0.11.10 test/net_http_transport_test.rb
roar-0.11.9 test/net_http_transport_test.rb
roar-0.11.8 test/net_http_transport_test.rb
roar-0.11.7 test/net_http_transport_test.rb
roar-0.11.6 test/net_http_transport_test.rb
roar-0.11.5 test/net_http_transport_test.rb