Sha256: e32048b81737b769ce3ae91cea8aeeb3016abcfa2f1336005215f5bb44851d5a

Contents?: true

Size: 837 Bytes

Versions: 13

Compression:

Stored size: 837 Bytes

Contents

class TestServerError < Test::Unit::TestCase
  def test_detects_error_with_env
    env = Faraday::Env.new
    env.status = 404
    env.body = {"itemNotFound"=>{"message"=>"Image not found.", "code"=>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.status = 599
    env.body = "<html>Not found.</html>"

    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

13 entries across 13 versions & 1 rubygems

Version Path
yao-0.21.0 test/yao/test_server_error.rb
yao-0.20.0 test/yao/test_server_error.rb
yao-0.19.0 test/yao/test_server_error.rb
yao-0.18.0 test/yao/test_server_error.rb
yao-0.17.0 test/yao/test_server_error.rb
yao-0.16.0 test/yao/test_server_error.rb
yao-0.15.0 test/yao/test_server_error.rb
yao-0.14.0 test/yao/test_server_error.rb
yao-0.13.4 test/yao/test_server_error.rb
yao-0.13.3 test/yao/test_server_error.rb
yao-0.13.2 test/yao/test_server_error.rb
yao-0.13.1 test/yao/test_server_error.rb
yao-0.13.0 test/yao/test_server_error.rb