Sha256: 9b42ec7090d1588c35469eeb76265442582582a2390098a49e90ddc4b09e581e

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require_relative 'minitest_helper'

describe TrackerApi do
  it 'has a version' do
    ::TrackerApi::VERSION.wont_be_nil
  end
end

describe TrackerApi::Client do
  it 'can be configured' do
    client = TrackerApi::Client.new(url:         'http://test.com',
                                    api_version: '/foo-bar/1',
                                    token:       '12345')

    client.url.must_equal 'http://test.com'
    client.api_version.must_equal '/foo-bar/1'
    client.token.must_equal '12345'
  end

  describe '.projects' do
    let(:pt_user) { PT_USER_1 }
    let(:client) { TrackerApi::Client.new token: pt_user[:token] }

    it 'gets all projects' do
      VCR.use_cassette('get all projects', record: :new_episodes) do
        projects = client.projects(fields: ':default,account,current_velocity,labels(name),epics(:default,label(name))')

        projects.wont_be_empty
        project = projects.first
        project.must_be_instance_of TrackerApi::Resources::Project
        project.id.must_equal pt_user[:project_id]

        project.account.must_be_instance_of TrackerApi::Resources::Account

        project.labels.wont_be_empty
        project.labels.first.must_be_instance_of TrackerApi::Resources::Label

        project.epics.wont_be_empty
        project.epics.first.must_be_instance_of TrackerApi::Resources::Epic
      end
    end
  end

  describe '.project' do
    let(:pt_user) { PT_USER_1 }
    let(:client) { TrackerApi::Client.new token: pt_user[:token] }
    let(:project_id) { pt_user[:project_id] }

    it 'gets a project by id' do
      VCR.use_cassette('get project', record: :new_episodes) do
        project = client.project(project_id)

        project.must_be_instance_of TrackerApi::Resources::Project
        project.id.must_equal project_id

        project.account.must_be_nil
        project.account_id.wont_be_nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracker_api-0.1.0 test/client_test.rb