Sha256: 0d9319223c66e6250e85a8125a2f1dd12a48b23f34786dcc404e2976312774dc

Contents?: true

Size: 1.58 KB

Versions: 22

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

class ClientTest < Lapse::TestCase
  def test_initialization
    client = Lapse::Client.new(:access_token => 'asdf1234')
    assert_equal 'asdf1234', client.access_token
    assert client.authenticated?

    client = Lapse::Client.new('asdf1234')
    assert_equal 'asdf1234', client.access_token

    client = Lapse::Client.new
    refute client.authenticated?
  end

  def test_base_url
    client = Lapse::Client.new
    assert_equal 'https://everlapse.com/api/v1/', client.base_url

    client = Lapse::Client.new(:api_scheme => 'http', :api_host => 'example.com', :api_version => 42)
    assert_equal 'http://example.com/api/v42/', client.base_url

    client = Lapse::Client.new(:api_url => 'http://example.com')
    assert_equal 'http://example.com/api/v1/', client.base_url

    client = Lapse::Client.new(:api_url => 'http://localhost:3000')
    assert_equal 'http://localhost:3000/api/v1/', client.base_url

    client = Lapse::Client.new(:api_prefix => 'asd')
    assert_equal 'https://everlapse.com/asd/v1/', client.base_url
  end

  def test_ssl?
    client = Lapse::Client.new
    assert client.ssl?

    client = Lapse::Client.new(:api_scheme => 'http')
    refute client.ssl?
  end

  def test_configuration
    Lapse::Client.configure do |client|
      client.api_host = 'blah'
      client.api_scheme = 'gopher'
      client.result_format = :hash
    end

    assert_equal 'blah', Lapse::Client.new.api_host
    assert_equal 'gopher', Lapse::Client.new.api_scheme
    Lapse::Client.new.result_format

    # forcibly reset the configuration
    Lapse::Client.options = nil
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lapse-0.1.0 test/lapse/client_test.rb
lapse-0.0.23 test/lapse/client_test.rb
lapse-0.0.22 test/lapse/client_test.rb
lapse-0.0.21 test/lapse/client_test.rb
lapse-0.0.20 test/lapse/client_test.rb
lapse-0.0.19 test/lapse/client_test.rb
lapse-0.0.18 test/lapse/client_test.rb
lapse-0.0.17 test/lapse/client_test.rb
lapse-0.0.16 test/lapse/client_test.rb
lapse-0.0.15 test/lapse/client_test.rb
lapse-0.0.14 test/lapse/client_test.rb
lapse-0.0.13 test/lapse/client_test.rb
lapse-0.0.12 test/lapse/client_test.rb
lapse-0.0.11 test/lapse/client_test.rb
lapse-0.0.10 test/lapse/client_test.rb
lapse-0.0.9 test/lapse/client_test.rb
lapse-0.0.8 test/lapse/client_test.rb
lapse-0.0.7 test/lapse/client_test.rb
lapse-0.0.6 test/lapse/client_test.rb
lapse-0.0.5 test/lapse/client_test.rb