Sha256: 8eb989c0d0acef8aced2cb6c0fc591ed4ef9500816c1811aa1b962416c6353a9

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'

describe FastlyRails::Client do

  let(:client) do
    FastlyRails::Client.new(
      :api_key => 'KEY'
    )
  end

  it 'should create a fastly rails client' do
    assert_instance_of FastlyRails::Client, client
  end

  it 'should be delegated to the fastly client' do
    assert_instance_of Fastly, client.instance_variable_get('@delegate_dc_obj')
  end

  # This is kind of a static-ish test that technically isn't necessary
  # But if we decide to lock down the methods available from the client
  # through this interface, we can ensure they're available via this test

  it 'should respond to methods available in the fastly client' do

    methods = [
      :purge,
      :get_service
    ]

    methods.each do |method|
      assert_respond_to client, method
    end

  end

  describe 'purge_by_key' do
    it 'raises if purge called and no service id configured' do
      FastlyRails.configuration.service_id = nil

      assert_raises FastlyRails::NoServiceIdProvidedError do
        client.purge_by_key('test')
      end
    end

    it 'should be authed' do
      assert_equal true, client.authed?
      assert_equal false, client.fully_authed?
    end

    describe 'when username and password are supplied' do
      before do
        client.client.user = 'USER'
        client.client.password = 'PASS'
      end

      it 'should be fully authed' do
        assert_equal true, client.authed?
        assert_equal true, client.fully_authed?
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fastly-rails-0.8.0 test/fastly-rails/client_test.rb
fastly-rails-0.7.1 test/fastly-rails/client_test.rb