Sha256: fadf488a83755b06362990b35427eb7d4e308823630363036e5834838b472c0e

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

class ResponseTest < Faraday::TestCase
  describe "unloaded response class" do
    it "is not allowed to be set" do
      resp_class = Object.new
      def resp_class.loaded?() false end
      conn = Faraday::Connection.new
      assert_raises ArgumentError do
        conn.response_class = resp_class
      end
    end
  end

  describe "TestConnection#get with default Faraday::Response class" do
    it "returns Faraday::Response" do
      conn = TestConnection.new do |stub|
        stub.get('/hello') { [200, {}, 'hello world']}
      end
      resp = conn.get('/hello')
      assert_equal 'hello world', resp.body
    end
  end

  describe "TestConnection#get with Faraday::YajlResponse class" do
    it "returns string body" do
      conn = TestConnection.new do |stub|
        stub.get('/hello') { [200, {}, '[1,2,3]']}
      end
      conn.response_class = Faraday::Response::YajlResponse
      assert_equal [1,2,3], conn.get('/hello').body
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faraday-0.0.1 test/response_test.rb