Sha256: 48a870464b22b1592f7c53bc6eb0e6634fa5949603ab88b4b9c3d59d65193319

Contents?: true

Size: 837 Bytes

Versions: 50

Compression:

Stored size: 837 Bytes

Contents

class TestServerError < Test::Unit::TestCase
  def test_detects_error_with_env
    env = Faraday::Env.new
    env.body = {"itemNotFound"=>{"message"=>"Image not found.", "code"=>404}}
    env.status = 404

    error = Yao::ServerError.detect(env)
    assert { error.is_a? Yao::ItemNotFound }
    assert { error.env.is_a? Faraday::Env }
    assert { error.status == 404 }
    assert { error.env.body["itemNotFound"]["message"] == "Image not found." }
  end

  def test_anyway_returns_error
    env = Faraday::Env.new
    env.body = "<html>Not found.</html>"
    env.status = 599

    error = Yao::ServerError.detect(env)
    assert { error.is_a? Yao::ServerError }
    assert { error.env.is_a? Faraday::Env }
    assert { error.status == 599 }
    assert { error.message == "Something is wrong. - \"<html>Not found.</html>\"" }
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
yao-0.12.0 test/yao/test_server_error.rb
yao-0.11.3 test/yao/test_server_error.rb
yao-0.11.2 test/yao/test_server_error.rb
yao-0.11.1 test/yao/test_server_error.rb
yao-0.11.0 test/yao/test_server_error.rb
yao-0.10.1 test/yao/test_server_error.rb
yao-0.10.0 test/yao/test_server_error.rb
yao-0.9.1 test/yao/test_server_error.rb
yao-0.9.0 test/yao/test_server_error.rb
yao-0.8.0 test/yao/test_server_error.rb
yao-0.7.0 test/yao/test_server_error.rb
yao-0.6.3 test/yao/test_server_error.rb
yao-0.6.2 test/yao/test_server_error.rb
yao-0.6.1 test/yao/test_server_error.rb
yao-0.6.0 test/yao/test_server_error.rb
yao-0.5.0 test/yao/test_server_error.rb
yao-0.4.3 test/yao/test_server_error.rb
yao-0.4.2 test/yao/test_server_error.rb
yao-0.4.1 test/yao/test_server_error.rb
yao-0.4.0 test/yao/test_server_error.rb