Sha256: 9c2dcf1571c08bf4a62fe0236e5370c7e0940fa69b97601eb11a4f754495504c

Contents?: true

Size: 983 Bytes

Versions: 22

Compression:

Stored size: 983 Bytes

Contents

class TestClientPlugin < Test::Unit::TestCase
  def setup
    stub(Yao.config).debug { false }
    stub(Yao.config).debug_record_response { false }
  end

  def teardown
    Yao.config.set :client_generator, :default
  end

  def test_raise_invalid_name
    e = nil
    begin
      Yao.config.set :client_generator, :nonexist
    rescue => e
    end

    assert { e.is_a? StandardError }
    assert { e.message == "Invalid client_generator name :nonexist.\nNote: name must be a Symbol" }
  end

  class ::Yao::Plugins::TestCustomClientGenerator
    def call(f, t)
      f.response :xml, :content_type => /\/xml$/
    end
    ::Yao::Plugins.register self, type: :client_generator, name: :test_custom
  end

  def test_gen_client_with_custom
    Yao.config.set :client_generator, :test_custom

    cli = Yao::Client.gen_client("http://cool-api.example.com:12345/v3.0")
    handlers = [
      FaradayMiddleware::ParseXml,
    ]
    assert { cli.builder.handlers == handlers }
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
yao-0.3.7 test/yao/test_client_plugin.rb
yao-0.3.6 test/yao/test_client_plugin.rb
yao-0.3.5 test/yao/test_client_plugin.rb
yao-0.3.4 test/yao/test_client_plugin.rb
yao-0.3.3 test/yao/test_client_plugin.rb
yao-0.3.2 test/yao/test_client_plugin.rb
yao-0.3.1 test/yao/test_client_plugin.rb
yao-0.3.0 test/yao/test_client_plugin.rb
yao-0.2.13 test/yao/test_client_plugin.rb
yao-0.2.12 test/yao/test_client_plugin.rb
yao-0.2.11 test/yao/test_client_plugin.rb
yao-0.2.10 test/yao/test_client_plugin.rb
yao-0.2.9 test/yao/test_client_plugin.rb
yao-0.2.8 test/yao/test_client_plugin.rb
yao-0.2.7 test/yao/test_client_plugin.rb
yao-0.2.6 test/yao/test_client_plugin.rb
yao-0.2.5 test/yao/test_client_plugin.rb
yao-0.2.4 test/yao/test_client_plugin.rb
yao-0.2.2 test/yao/test_client_plugin.rb
yao-0.2.1 test/yao/test_client_plugin.rb