Sha256: 5b4514b8bfaa77ccb8805d9b7b609f9b30243868a6ee4bd04b35a16aceace510

Contents?: true

Size: 1.9 KB

Versions: 15

Compression:

Stored size: 1.9 KB

Contents

Shindo.tests('HTTPStatusError request/response debugging') do

  tests('new raises errors for bad URIs').returns(true) do
    begin
      Excon.new('foo')
      false
    rescue => err
      err.to_s.include? 'foo'
    end
  end

  with_server('error') do

    tests('message does not include response or response info').returns(true) do
      begin
        Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200)
      rescue => err
        err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
        !err.message.include?('request =>') &&
        !err.message.include?('response =>')
      end
    end

    tests('message includes only response info').returns(true) do
      begin
        Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200,
                  :debug_response => true)
      rescue => err
        err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
        !err.message.include?('request =>') &&
        !!(err.message =~ /response =>(.*)server says not found/)
      end
    end

    tests('message includes only request info').returns(true) do
      begin
        Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200,
                  :debug_request => true)
      rescue => err
        err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
        !!(err.message =~ /request =>(.*)error\/not_found/) &&
        !err.message.include?('response =>')
      end
    end

    tests('message include request and response info').returns(true) do
      begin
        Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200,
                  :debug_request => true, :debug_response => true)
      rescue => err
        err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
        !!(err.message =~ /request =>(.*)not_found/) &&
        !!(err.message =~ /response =>(.*)server says not found/)
      end
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
excon-0.38.0 tests/errors_tests.rb
excon-0.37.0 tests/errors_tests.rb
excon-0.36.0 tests/errors_tests.rb
excon-0.35.0 tests/errors_tests.rb
excon-0.34.0 tests/errors_tests.rb
excon-0.33.0 tests/errors_tests.rb
excon-0.32.1 tests/errors_tests.rb
excon-0.32.0 tests/errors_tests.rb
excon-0.31.0 tests/errors_tests.rb
excon-0.30.0 tests/errors_tests.rb
excon-0.29.0 tests/errors_tests.rb
excon-0.28.0 tests/errors_tests.rb
excon-0.27.6 tests/errors_tests.rb
excon-0.27.5 tests/errors_tests.rb
excon-0.27.4 tests/errors_tests.rb