Sha256: 8260b445a3dc38c31ee7f0987bb0e94bb860a4ee77e47829629e4a8218b38a09

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

class ApiTest < ActiveSupport::TestCase
  context 'Api' do
    context '#initalize' do
      should 'raise a MissingAttribute error for a missing email' do
        e = assert_raises EspSdk::MissingAttribute do
          EspSdk::Api.new({ })
        end
        assert_equal 'Missing required email', e.message

      end
      should 'raise a MissingAttribute error for a missing token and password' do
        e = assert_raises EspSdk::MissingAttribute do
          EspSdk::Api.new(email: 'test@evident.io')
        end
        assert_equal 'Missing required password or token', e.message

      end

      should 'define our endpoint methods and add them to the end_points array' do
        # Stub the token setup for our configuration object
        EspSdk::Configure.any_instance.expects(:token_setup).returns(nil).at_least_once
        api = EspSdk::Api.new(email: 'test@evident.io', password: 'password')
        end_points = (EspSdk::EndPoints.constants - [:Base]).map(&:to_s).map(&:underscore)
        methods = api.singleton_methods.map(&:to_s)

        assert_equal end_points.count, api.end_points.count

        methods.each do |method|
          assert_includes end_points, method
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
esp_sdk-1.0.5 test/esp_sdk/api_test.rb
esp_sdk-1.0.4 test/esp_sdk/api_test.rb
esp_sdk-1.0.3 test/esp_sdk/api_test.rb
esp_sdk-1.0.2 test/esp_sdk/api_test.rb
esp_sdk-1.0.1 test/esp_sdk/api_test.rb
esp_sdk-1.0.0 test/esp_sdk/api_test.rb