Sha256: 44c0de80b14d438fa07a12614e4c5daaa57aa2ca45adf6e6455c95e2c943100c

Contents?: true

Size: 953 Bytes

Versions: 42

Compression:

Stored size: 953 Bytes

Contents

Shindo.tests("Excon support for middlewares that return canned responses") do
  the_body = "canned"

  canned_response_middleware = Class.new(Excon::Middleware::Base) do
    define_method :request_call do |params|
      params[:response] = {
        :body     => the_body,
        :headers  => {},
        :status   => 200
      }
      super(params)
    end
  end

  tests('does not mutate the canned response body').returns(the_body) do
    Excon.get(
      'http://some-host.com/some-path',
      :middlewares    => [canned_response_middleware] + Excon.defaults[:middlewares]
    ).body
  end

  tests('yields non-mutated body to response_block').returns(the_body) do
    body = ''
    response_block = lambda { |chunk, _, _| body << chunk }
    Excon.get(
      'http://some-host.com/some-path',
      :middlewares    => [canned_response_middleware] + Excon.defaults[:middlewares],
      :response_block => response_block
    )
    body
  end

end

Version data entries

42 entries across 40 versions & 4 rubygems

Version Path
excon-0.64.0 tests/middlewares/canned_response_tests.rb
excon-0.63.0 tests/middlewares/canned_response_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/excon-0.62.0/tests/middlewares/canned_response_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/excon-0.62.0/tests/middlewares/canned_response_tests.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/excon-0.62.0/tests/middlewares/canned_response_tests.rb
excon-0.62.0 tests/middlewares/canned_response_tests.rb
excon-0.61.0 tests/middlewares/canned_response_tests.rb
excon-0.60.0 tests/middlewares/canned_response_tests.rb
excon-0.59.0 tests/middlewares/canned_response_tests.rb
excon-0.58.0 tests/middlewares/canned_response_tests.rb
excon-0.57.1 tests/middlewares/canned_response_tests.rb
excon-0.57.0 tests/middlewares/canned_response_tests.rb
excon-0.56.0 tests/middlewares/canned_response_tests.rb
excon-0.55.0 tests/middlewares/canned_response_tests.rb
excon-0.54.0 tests/middlewares/canned_response_tests.rb
excon-0.53.0 tests/middlewares/canned_response_tests.rb
excon-0.52.0 tests/middlewares/canned_response_tests.rb
excon-0.51.0 tests/middlewares/canned_response_tests.rb
excon-0.50.1 tests/middlewares/canned_response_tests.rb
excon-0.50.0 tests/middlewares/canned_response_tests.rb