Sha256: 136cb2205ba1288631b542b32498be1b3b92c38dbc3e753f61f5e2c09737789a

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

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

class ResponseMiddlewareTest < Faraday::TestCase
  describe "parsing json" do
    [:yajl, :rails_json].each do |key|
      parser = Faraday::Response.lookup_module(key)
      next if !parser.loaded?
      it "uses #{parser}" do
        @connection = Faraday::Connection.new do |b|
          b.adapter :test do |stub|
            stub.get('json') { [200, {'Content-Type' => 'text/html'}, "[1,2,3]"] }
          end
          b.use parser
        end
        response = @connection.get('json')
        assert response.success?
        assert_equal [1,2,3], response.body
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
faraday-0.2.1 test/response_middleware_test.rb
faraday-0.2.0 test/response_middleware_test.rb