Sha256: 48abeb9eb47115bc8bf2a8f288d70763f173a78fe8e94f8e50877cbcbb2fa3c8

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require File.join(File.dirname(__FILE__), '../../test_helper')

describe HammerCLI::Apipie::ApiConnection do
  let(:connection) { HammerCLI::Connection.new }

  describe '#initialize' do

    let(:empty_params) {{}}

    def api_stub(params = {})
      api_stub = stub()
      ApipieBindings::API.expects(:new).with(params).returns(api_stub)
      api_stub
    end

    it "passes attributes to apipie bindings" do
      params = { :apidoc_cache_name => 'test.example.com' }

      api_stub(params)
      HammerCLI::Apipie::ApiConnection.new(params)
    end

    context "with :clear_cache => true" do
      it "clears cache" do
        api_stub.expects(:clean_cache)
        HammerCLI::Apipie::ApiConnection.new(empty_params, :reload_cache => true)
      end

      it "logs message when logger is available" do
        logger = stub()
        logger.expects(:debug).with('Apipie cache was cleared')

        api_stub.expects(:clean_cache)
        HammerCLI::Apipie::ApiConnection.new(empty_params, :reload_cache => true, :logger => logger)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hammer_cli-0.9.0 test/unit/apipie/api_connection_test.rb