Sha256: 00f16c88e6a54e93de367cb6d8c62dc97fd75b1627587e0f6fd8732573d775bc

Contents?: true

Size: 1.94 KB

Versions: 33

Compression:

Stored size: 1.94 KB

Contents

describe 'Request API /v1/build_distributions/subset' do
  let(:valid_endpoint) { 'http://api.knapsackpro.dev:3000' }
  let(:invalid_endpoint) { 'http://api.fake-knapsackpro.dev:3000' }
  let(:valid_test_suite_token) { '3fa64859337f6e56409d49f865d13fd7' }
  let(:invalid_test_suite_token) { 'fake' }

  let(:action) do
    KnapsackPro::Client::API::V1::BuildDistributions.subset(
      commit_hash: 'abcdefg',
      branch: 'master',
      node_total: '2',
      node_index: '1',
      test_files: [
        {
          'path' => 'a_spec.rb'
        },
        {
          'path' => 'b_spec.rb'
        }
      ],
    )
  end
  let(:connection) { KnapsackPro::Client::Connection.new(action) }
  let(:endpoint) { valid_endpoint }
  let(:test_suite_token) { valid_test_suite_token }

  before do
    stub_const('ENV', {
      'KNAPSACK_PRO_ENDPOINT' => endpoint,
      'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
    })
  end

  context 'when success' do
    it do
      VCR.use_cassette('api/v1/build_distributions/subset/success') do
        response = connection.call
        puts response
      end

      expect(connection.errors?).to be false
      expect(connection.success?).to be true
    end
  end

  context 'when invalid test suite token' do
    let(:test_suite_token) { invalid_test_suite_token }

    it do
      VCR.use_cassette('api/v1/build_distributions/subset/invalid_test_suite_token') do
        response = connection.call
        puts response
      end

      expect(connection.errors?).to be true
      expect(connection.success?).to be true
    end
  end

  context 'when timeout' do
    let(:endpoint) { invalid_endpoint }

    it do
      stub_const('KnapsackPro::Client::Connection::TIMEOUT', 0.01)
      VCR.use_cassette('api/v1/build_distributions/subset/timeout') do
        response = connection.call
        puts response
      end

      expect(connection.errors?).to be false
      expect(connection.success?).to be false
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
knapsack_pro-0.25.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.24.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.23.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.22.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.21.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.20.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.19.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.18.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.17.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.16.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.15.2 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.15.1 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.15.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.14.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.13.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.12.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.11.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.10.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.9.0 spec/integration/api/build_distributions_subset_spec.rb
knapsack_pro-0.8.0 spec/integration/api/build_distributions_subset_spec.rb