travis 1.11.1 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/Rakefile +22 -20
- data/bin/travis +5 -3
- data/examples/org_overview.rb +2 -0
- data/examples/pro_auth.rb +3 -1
- data/examples/stream.rb +5 -3
- data/lib/travis/auto_login.rb +2 -0
- data/lib/travis/cli/accounts.rb +12 -9
- data/lib/travis/cli/api_command.rb +85 -81
- data/lib/travis/cli/branches.rb +8 -6
- data/lib/travis/cli/cache.rb +48 -44
- data/lib/travis/cli/cancel.rb +4 -2
- data/lib/travis/cli/command.rb +170 -142
- data/lib/travis/cli/console.rb +5 -5
- data/lib/travis/cli/disable.rb +4 -2
- data/lib/travis/cli/enable.rb +14 -12
- data/lib/travis/cli/encrypt.rb +57 -57
- data/lib/travis/cli/encrypt_file.rb +29 -18
- data/lib/travis/cli/endpoint.rb +9 -7
- data/lib/travis/cli/env.rb +13 -8
- data/lib/travis/cli/help.rb +10 -8
- data/lib/travis/cli/history.rb +19 -15
- data/lib/travis/cli/init.rb +27 -24
- data/lib/travis/cli/lint.rb +10 -8
- data/lib/travis/cli/login.rb +17 -11
- data/lib/travis/cli/logout.rb +4 -2
- data/lib/travis/cli/logs.rb +28 -19
- data/lib/travis/cli/monitor.rb +11 -8
- data/lib/travis/cli/open.rb +17 -14
- data/lib/travis/cli/parser.rb +2 -0
- data/lib/travis/cli/pubkey.rb +13 -11
- data/lib/travis/cli/raw.rb +4 -3
- data/lib/travis/cli/repo_command.rb +123 -112
- data/lib/travis/cli/report.rb +40 -33
- data/lib/travis/cli/repos.rb +14 -9
- data/lib/travis/cli/requests.rb +13 -12
- data/lib/travis/cli/restart.rb +4 -2
- data/lib/travis/cli/settings.rb +41 -35
- data/lib/travis/cli/setup/anynines.rb +7 -6
- data/lib/travis/cli/setup/appfog.rb +6 -4
- data/lib/travis/cli/setup/artifacts.rb +7 -5
- data/lib/travis/cli/setup/biicode.rb +6 -4
- data/lib/travis/cli/setup/cloud_66.rb +6 -4
- data/lib/travis/cli/setup/cloud_control.rb +8 -6
- data/lib/travis/cli/setup/cloud_files.rb +7 -5
- data/lib/travis/cli/setup/cloud_foundry.rb +9 -7
- data/lib/travis/cli/setup/code_deploy.rb +33 -29
- data/lib/travis/cli/setup/deis.rb +8 -6
- data/lib/travis/cli/setup/divshot.rb +20 -18
- data/lib/travis/cli/setup/elastic_beanstalk.rb +10 -8
- data/lib/travis/cli/setup/engine_yard.rb +9 -7
- data/lib/travis/cli/setup/gcs.rb +9 -7
- data/lib/travis/cli/setup/hackage.rb +6 -4
- data/lib/travis/cli/setup/heroku.rb +10 -4
- data/lib/travis/cli/setup/modulus.rb +5 -3
- data/lib/travis/cli/setup/ninefold.rb +7 -5
- data/lib/travis/cli/setup/nodejitsu.rb +6 -4
- data/lib/travis/cli/setup/npm.rb +6 -4
- data/lib/travis/cli/setup/open_shift.rb +8 -6
- data/lib/travis/cli/setup/opsworks.rb +24 -22
- data/lib/travis/cli/setup/pypi.rb +7 -5
- data/lib/travis/cli/setup/releases.rb +6 -6
- data/lib/travis/cli/setup/ruby_gems.rb +7 -5
- data/lib/travis/cli/setup/s3.rb +12 -8
- data/lib/travis/cli/setup/sauce_connect.rb +7 -5
- data/lib/travis/cli/setup/service.rb +36 -25
- data/lib/travis/cli/setup.rb +7 -3
- data/lib/travis/cli/show.rb +10 -8
- data/lib/travis/cli/sshkey.rb +31 -27
- data/lib/travis/cli/status.rb +5 -3
- data/lib/travis/cli/sync.rb +9 -7
- data/lib/travis/cli/token.rb +4 -2
- data/lib/travis/cli/version.rb +4 -3
- data/lib/travis/cli/whatsup.rb +10 -8
- data/lib/travis/cli/whoami.rb +2 -2
- data/lib/travis/cli.rb +39 -36
- data/lib/travis/client/account.rb +8 -6
- data/lib/travis/client/artifact.rb +16 -12
- data/lib/travis/client/auto_login.rb +7 -4
- data/lib/travis/client/broadcast.rb +2 -0
- data/lib/travis/client/build.rb +7 -3
- data/lib/travis/client/cache.rb +4 -2
- data/lib/travis/client/commit.rb +5 -2
- data/lib/travis/client/entity.rb +50 -46
- data/lib/travis/client/env_var.rb +13 -8
- data/lib/travis/client/error.rb +5 -3
- data/lib/travis/client/has_uuid.rb +3 -1
- data/lib/travis/client/job.rb +8 -3
- data/lib/travis/client/lint_result.rb +2 -0
- data/lib/travis/client/listener.rb +70 -55
- data/lib/travis/client/methods.rb +10 -5
- data/lib/travis/client/namespace.rb +20 -16
- data/lib/travis/client/not_loadable.rb +3 -1
- data/lib/travis/client/repository.rb +34 -22
- data/lib/travis/client/request.rb +5 -2
- data/lib/travis/client/restartable.rb +2 -0
- data/lib/travis/client/session.rb +118 -88
- data/lib/travis/client/settings.rb +8 -3
- data/lib/travis/client/singleton_setting.rb +2 -0
- data/lib/travis/client/ssh_key.rb +2 -0
- data/lib/travis/client/states.rb +8 -6
- data/lib/travis/client/user.rb +2 -0
- data/lib/travis/client/weak_entity.rb +6 -3
- data/lib/travis/client.rb +4 -1
- data/lib/travis/pro/auto_login.rb +2 -0
- data/lib/travis/pro.rb +2 -0
- data/lib/travis/tools/assets.rb +6 -3
- data/lib/travis/tools/completion.rb +10 -6
- data/lib/travis/tools/formatter.rb +20 -14
- data/lib/travis/tools/github.rb +59 -49
- data/lib/travis/tools/notification.rb +18 -13
- data/lib/travis/tools/safe_string.rb +4 -1
- data/lib/travis/tools/ssl_key.rb +5 -2
- data/lib/travis/tools/system.rb +11 -6
- data/lib/travis/version.rb +3 -1
- data/lib/travis.rb +3 -1
- data/spec/cli/api_command_spec.rb +11 -8
- data/spec/cli/cancel_spec.rb +2 -4
- data/spec/cli/encrypt_file_spec.rb +9 -7
- data/spec/cli/encrypt_spec.rb +19 -17
- data/spec/cli/endpoint_spec.rb +12 -10
- data/spec/cli/help_spec.rb +14 -12
- data/spec/cli/history_spec.rb +2 -0
- data/spec/cli/init_spec.rb +35 -33
- data/spec/cli/logs_spec.rb +2 -0
- data/spec/cli/open_spec.rb +6 -4
- data/spec/cli/repo_command_spec.rb +8 -4
- data/spec/cli/restart_spec.rb +2 -4
- data/spec/cli/setup/service_spec.rb +17 -18
- data/spec/cli/setup_spec.rb +2 -4
- data/spec/cli/show_spec.rb +4 -2
- data/spec/cli/status_spec.rb +7 -5
- data/spec/cli/token_spec.rb +7 -5
- data/spec/cli/version_spec.rb +2 -0
- data/spec/cli/whoami_spec.rb +9 -7
- data/spec/client/account_spec.rb +28 -20
- data/spec/client/auto_login_spec.rb +12 -9
- data/spec/client/broadcast_spec.rb +5 -3
- data/spec/client/build_spec.rb +28 -24
- data/spec/client/commit_spec.rb +17 -14
- data/spec/client/job_spec.rb +27 -23
- data/spec/client/methods_spec.rb +8 -4
- data/spec/client/namespace_spec.rb +8 -4
- data/spec/client/repository_spec.rb +33 -30
- data/spec/client/session_spec.rb +71 -67
- data/spec/client/user_spec.rb +13 -10
- data/spec/client_spec.rb +6 -4
- data/spec/pro_spec.rb +5 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/support/fake_api.rb +662 -662
- data/spec/support/fake_github.rb +6 -3
- data/spec/support/helpers.rb +13 -8
- data/spec/travis_spec.rb +5 -3
- data/travis.gemspec +400 -399
- metadata +30 -50
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/client/auto_login'
|
2
4
|
require 'spec_helper'
|
3
5
|
|
4
6
|
describe Travis::Client::AutoLogin do
|
5
|
-
let(:auto_login_with_token) {
|
6
|
-
let(:auto_login_without_token) {
|
7
|
-
let(:travis_config) { File.expand_path(
|
7
|
+
let(:auto_login_with_token) { described_class.new(Travis::Client.new, { config_file: travis_config }) }
|
8
|
+
let(:auto_login_without_token) { described_class.new(Travis::Client.new) }
|
9
|
+
let(:travis_config) { File.expand_path('../support/fake_travis_config.yml', File.dirname(__FILE__)) }
|
8
10
|
|
9
|
-
context
|
10
|
-
context
|
11
|
-
it
|
12
|
-
expect_any_instance_of(Travis::Tools::Github).
|
11
|
+
context 'when user authenticates' do
|
12
|
+
context 'when user has a token in cli config' do
|
13
|
+
it 'does not call Tools::Github#with_token' do
|
14
|
+
expect_any_instance_of(Travis::Tools::Github).not_to receive(:with_token)
|
13
15
|
auto_login_with_token.authenticate
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
context
|
19
|
+
context 'when user does not have a token in cli config' do
|
18
20
|
before { auto_login_without_token.github.stub(:with_token).and_return(true) }
|
19
|
-
|
21
|
+
|
22
|
+
it 'calls Tools::Github#with_token' do
|
20
23
|
expect(auto_login_without_token.github).to receive(:with_token)
|
21
24
|
auto_login_without_token.authenticate
|
22
25
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Broadcast do
|
4
|
-
let(:session) { Travis::Client.new }
|
5
6
|
subject { session.broadcasts.first }
|
6
7
|
|
7
|
-
|
8
|
-
its(:message) { should be == "Hello!" }
|
8
|
+
let(:session) { Travis::Client.new }
|
9
9
|
|
10
|
+
its(:id) { is_expected.to be == 1 }
|
11
|
+
its(:message) { is_expected.to be == 'Hello!' }
|
10
12
|
end
|
data/spec/client/build_spec.rb
CHANGED
@@ -1,31 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Build do
|
6
|
+
subject { session.build(4_125_095) }
|
7
|
+
|
4
8
|
let(:session) { Travis::Client.new }
|
5
|
-
subject { session.build(4125095) }
|
6
|
-
its(:number) { should be == '6180' }
|
7
|
-
its(:state) { should be == 'failed' }
|
8
|
-
its(:duration) { should be == 5019 }
|
9
|
-
its(:started_at) { should be_a(Time) }
|
10
|
-
its(:finished_at) { should be_nil }
|
11
|
-
its(:inspect) { should be == "#<Travis::Client::Build: rails/rails#6180>" }
|
12
|
-
its(:color) { should be == 'red' }
|
13
|
-
its(:commit) { should be_a(Travis::Client::Commit) }
|
14
|
-
its(:jobs) { should be_an(Array) }
|
15
|
-
its(:repository) { should be == session.repo('rails/rails') }
|
16
9
|
|
17
|
-
|
10
|
+
its(:number) { is_expected.to be == '6180' }
|
11
|
+
its(:state) { is_expected.to be == 'failed' }
|
12
|
+
its(:duration) { is_expected.to be == 5019 }
|
13
|
+
its(:started_at) { is_expected.to be_a(Time) }
|
14
|
+
its(:finished_at) { is_expected.to be_nil }
|
15
|
+
its(:inspect) { is_expected.to be == '#<Travis::Client::Build: rails/rails#6180>' }
|
16
|
+
its(:color) { is_expected.to be == 'red' }
|
17
|
+
its(:commit) { is_expected.to be_a(Travis::Client::Commit) }
|
18
|
+
its(:jobs) { is_expected.to be_an(Array) }
|
19
|
+
its(:repository) { is_expected.to be == session.repo('rails/rails') }
|
20
|
+
|
21
|
+
it { is_expected.to be == subject.repository.last_build }
|
18
22
|
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
23
|
+
it { is_expected.not_to be_pending }
|
24
|
+
it { is_expected.to be_started }
|
25
|
+
it { is_expected.to be_finished }
|
26
|
+
it { is_expected.not_to be_passed }
|
27
|
+
it { is_expected.not_to be_errored }
|
28
|
+
it { is_expected.to be_failed }
|
29
|
+
it { is_expected.not_to be_canceled }
|
30
|
+
it { is_expected.to be_created }
|
31
|
+
it { is_expected.to be_red }
|
32
|
+
it { is_expected.not_to be_green }
|
33
|
+
it { is_expected.not_to be_yellow }
|
34
|
+
it { is_expected.to be_unsuccessful }
|
31
35
|
end
|
data/spec/client/commit_spec.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Build do
|
6
|
+
subject { session.build(4_125_095).commit }
|
7
|
+
|
4
8
|
let(:session) { Travis::Client.new }
|
5
|
-
subject { session.build(4125095).commit }
|
6
9
|
|
7
|
-
its(:sha) {
|
8
|
-
its(:short_sha) {
|
9
|
-
its(:branch) {
|
10
|
-
its(:message) {
|
11
|
-
its(:committed_at) {
|
12
|
-
its(:author_name) {
|
13
|
-
its(:author_email) {
|
14
|
-
its(:committer_name) {
|
15
|
-
its(:committer_email) {
|
16
|
-
its(:compare_url) {
|
17
|
-
its(:subject) {
|
10
|
+
its(:sha) { is_expected.to be == 'a0265b98f16c6e33be32aa3f57231d1189302400' }
|
11
|
+
its(:short_sha) { is_expected.to be == 'a0265b9' }
|
12
|
+
its(:branch) { is_expected.to be == 'master' }
|
13
|
+
its(:message) { is_expected.to be == 'Associaton -> Association' }
|
14
|
+
its(:committed_at) { is_expected.to be_a(Time) }
|
15
|
+
its(:author_name) { is_expected.to be == 'Steve Klabnik' }
|
16
|
+
its(:author_email) { is_expected.to be == 'steve@steveklabnik.com' }
|
17
|
+
its(:committer_name) { is_expected.to be == 'Steve Klabnik' }
|
18
|
+
its(:committer_email) { is_expected.to be == 'steve@steveklabnik.com' }
|
19
|
+
its(:compare_url) { is_expected.to be == 'https://github.com/rails/rails/compare/6581d798e830...a0265b98f16c' }
|
20
|
+
its(:subject) { is_expected.to be == 'Associaton -> Association' }
|
18
21
|
|
19
|
-
specify
|
20
|
-
session.load(
|
22
|
+
specify 'with missing data' do
|
23
|
+
session.load('commit' => { 'id' => 12 })['commit'].subject.should be_empty
|
21
24
|
end
|
22
25
|
end
|
data/spec/client/job_spec.rb
CHANGED
@@ -1,30 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Job do
|
6
|
+
subject { session.job(4_125_097) }
|
7
|
+
|
4
8
|
let(:session) { Travis::Client.new }
|
5
|
-
subject { session.job(4125097) }
|
6
|
-
its(:number) { should be == '6180.2' }
|
7
|
-
its(:state) { should be == 'passed' }
|
8
|
-
its(:started_at) { should be_a(Time) }
|
9
|
-
its(:finished_at) { should be_a(Time) }
|
10
|
-
its(:inspect) { should be == "#<Travis::Client::Job: rails/rails#6180.2>" }
|
11
|
-
its(:color) { should be == 'green' }
|
12
|
-
its(:commit) { should be_a(Travis::Client::Commit) }
|
13
|
-
its(:repository) { should be == session.repo('rails/rails') }
|
14
|
-
its(:duration) { should be == 905 }
|
15
9
|
|
16
|
-
|
10
|
+
its(:number) { is_expected.to be == '6180.2' }
|
11
|
+
its(:state) { is_expected.to be == 'passed' }
|
12
|
+
its(:started_at) { is_expected.to be_a(Time) }
|
13
|
+
its(:finished_at) { is_expected.to be_a(Time) }
|
14
|
+
its(:inspect) { is_expected.to be == '#<Travis::Client::Job: rails/rails#6180.2>' }
|
15
|
+
its(:color) { is_expected.to be == 'green' }
|
16
|
+
its(:commit) { is_expected.to be_a(Travis::Client::Commit) }
|
17
|
+
its(:repository) { is_expected.to be == session.repo('rails/rails') }
|
18
|
+
its(:duration) { is_expected.to be == 905 }
|
19
|
+
|
20
|
+
it { is_expected.to be == subject.build.jobs[1] }
|
17
21
|
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
22
|
+
it { is_expected.not_to be_pending }
|
23
|
+
it { is_expected.to be_started }
|
24
|
+
it { is_expected.to be_finished }
|
25
|
+
it { is_expected.to be_passed }
|
26
|
+
it { is_expected.not_to be_errored }
|
27
|
+
it { is_expected.not_to be_failed }
|
28
|
+
it { is_expected.not_to be_canceled }
|
29
|
+
it { is_expected.to be_created }
|
30
|
+
it { is_expected.not_to be_red }
|
31
|
+
it { is_expected.to be_green }
|
32
|
+
it { is_expected.not_to be_yellow }
|
33
|
+
it { is_expected.not_to be_unsuccessful }
|
30
34
|
end
|
data/spec/client/methods_spec.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Methods do
|
6
|
+
subject { OpenStruct.new(session:).extend(described_class) }
|
7
|
+
|
4
8
|
let(:session) { Travis::Client.new }
|
5
|
-
|
9
|
+
|
6
10
|
before { subject.access_token = 'token' }
|
7
11
|
|
8
|
-
its(:api_endpoint) {
|
9
|
-
its(:repos) {
|
10
|
-
its(:user) {
|
12
|
+
its(:api_endpoint) { is_expected.to be == 'https://api.travis-ci.com/' }
|
13
|
+
its(:repos) { is_expected.to be == session.find_many(Travis::Client::Repository) }
|
14
|
+
its(:user) { is_expected.to be == session.find_one(Travis::Client::User) }
|
11
15
|
|
12
16
|
it 'fetches a single repo' do
|
13
17
|
subject.repo(891).slug.should be == 'rails/rails'
|
@@ -1,18 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Namespace do
|
4
|
-
|
6
|
+
subject(:namespace) { described_class.new }
|
7
|
+
|
8
|
+
it { is_expected.to be_a(Travis::Client::Methods) }
|
5
9
|
|
6
10
|
it 'creates a dummy for repos' do
|
7
|
-
repo =
|
11
|
+
repo = namespace::Repository
|
8
12
|
repo.find_one('rails/rails').should be_a(Travis::Client::Repository)
|
9
13
|
repo.find_many.should be_an(Array)
|
10
14
|
repo.current.should be == repo.find_many
|
11
15
|
end
|
12
16
|
|
13
17
|
it 'creates a dummy for user' do
|
14
|
-
|
15
|
-
user =
|
18
|
+
namespace.access_token = 'token'
|
19
|
+
user = namespace::User
|
16
20
|
user.find_one.should be_a(Travis::Client::User)
|
17
21
|
user.current.should be == user.find_one
|
18
22
|
end
|
@@ -1,39 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Repository do
|
6
|
+
subject(:repository) { session.repo('rails/rails') }
|
7
|
+
|
4
8
|
let(:session) { Travis::Client.new }
|
5
|
-
subject { session.repo('rails/rails') }
|
6
9
|
|
7
|
-
its(:slug) {
|
8
|
-
its(:description) {
|
9
|
-
its(:last_build_id) {
|
10
|
-
its(:last_build_number) {
|
11
|
-
its(:last_build_state) {
|
12
|
-
its(:last_build_duration) {
|
13
|
-
its(:last_build_started_at) {
|
14
|
-
its(:last_build_finished_at) {
|
15
|
-
its(:inspect) {
|
16
|
-
its(:key) {
|
17
|
-
its(:last_build) {
|
18
|
-
its(:color) {
|
19
|
-
its(:github_language) {
|
20
|
-
its(:owner_name) {
|
21
|
-
its(:owner) {
|
10
|
+
its(:slug) { is_expected.to be == 'rails/rails' }
|
11
|
+
its(:description) { is_expected.not_to be_empty }
|
12
|
+
its(:last_build_id) { is_expected.to be == 4_125_095 }
|
13
|
+
its(:last_build_number) { is_expected.to be == '6180' }
|
14
|
+
its(:last_build_state) { is_expected.to be == 'failed' }
|
15
|
+
its(:last_build_duration) { is_expected.to be == 5019 }
|
16
|
+
its(:last_build_started_at) { is_expected.to be_a(Time) }
|
17
|
+
its(:last_build_finished_at) { is_expected.to be_nil }
|
18
|
+
its(:inspect) { is_expected.to be == '#<Travis::Client::Repository: rails/rails>' }
|
19
|
+
its(:key) { is_expected.to be_a(Travis::Client::Repository::Key) }
|
20
|
+
its(:last_build) { is_expected.to be_a(Travis::Client::Build) }
|
21
|
+
its(:color) { is_expected.to be == 'red' }
|
22
|
+
its(:github_language) { is_expected.to be == 'Ruby' }
|
23
|
+
its(:owner_name) { is_expected.to be == 'rails' }
|
24
|
+
its(:owner) { is_expected.to be == session.account('rails') }
|
22
25
|
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
34
|
-
it {
|
26
|
+
it { is_expected.not_to be_pending }
|
27
|
+
it { is_expected.to be_started }
|
28
|
+
it { is_expected.to be_finished }
|
29
|
+
it { is_expected.not_to be_passed }
|
30
|
+
it { is_expected.not_to be_errored }
|
31
|
+
it { is_expected.to be_failed }
|
32
|
+
it { is_expected.not_to be_canceled }
|
33
|
+
it { is_expected.to be_created }
|
34
|
+
it { is_expected.to be_red }
|
35
|
+
it { is_expected.not_to be_green }
|
36
|
+
it { is_expected.not_to be_yellow }
|
37
|
+
it { is_expected.to be_unsuccessful }
|
35
38
|
|
36
|
-
it '
|
37
|
-
|
39
|
+
it 'exposes the pubkey fingerprint' do
|
40
|
+
repository.public_key.fingerprint.should be == 'foobar'
|
38
41
|
end
|
39
42
|
end
|
data/spec/client/session_spec.rb
CHANGED
@@ -1,165 +1,169 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::Session do
|
4
|
-
|
6
|
+
subject(:session) { described_class.new }
|
7
|
+
|
8
|
+
it { is_expected.to be_a(Travis::Client::Methods) }
|
5
9
|
|
6
|
-
describe
|
7
|
-
its(:uri) {
|
10
|
+
describe 'uri' do
|
11
|
+
its(:uri) { is_expected.to be == 'https://api.travis-ci.com/' }
|
8
12
|
|
9
13
|
it 'can be set as argument' do
|
10
|
-
|
14
|
+
described_class.new('http://foo/').uri.should be == 'http://foo/'
|
11
15
|
end
|
12
16
|
|
13
17
|
it 'can be set as hash argument' do
|
14
|
-
|
18
|
+
described_class.new(uri: 'http://foo/').uri.should be == 'http://foo/'
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
describe
|
19
|
-
its(:access_token) {
|
22
|
+
describe 'access_token' do
|
23
|
+
its(:access_token) { is_expected.to be_nil }
|
20
24
|
|
21
25
|
it 'gives authenticated access if set' do
|
22
|
-
|
23
|
-
|
26
|
+
session.access_token = 'token'
|
27
|
+
session.user.login.should be == 'rkh'
|
24
28
|
end
|
25
29
|
|
26
30
|
it 'raises if token is not set' do
|
27
|
-
expect {
|
31
|
+
expect { session.user.login }.to raise_error(Travis::Client::Error)
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
|
-
describe
|
32
|
-
its(:connection) {
|
35
|
+
describe 'connection' do
|
36
|
+
its(:connection) { is_expected.to be_a(Faraday::Connection) }
|
33
37
|
|
34
38
|
it 'creates a new connection when changing the uri' do
|
35
|
-
old_connection =
|
36
|
-
|
37
|
-
|
39
|
+
old_connection = session.connection
|
40
|
+
session.uri = 'http://localhost:3000'
|
41
|
+
session.connection.should_not be == old_connection
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
|
-
describe
|
45
|
+
describe 'headers' do
|
42
46
|
it 'propagates headers to connection headers' do
|
43
|
-
|
44
|
-
|
47
|
+
session.headers['foo'] = 'bar'
|
48
|
+
session.connection.headers.should include('foo')
|
45
49
|
end
|
46
50
|
|
47
51
|
it 'propagates headers to new connections' do
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
session.headers['foo'] = 'bar'
|
53
|
+
session.connection = Faraday::Connection.new
|
54
|
+
session.connection.headers.should include('foo')
|
51
55
|
end
|
52
56
|
|
53
57
|
it 'is possible to set headers as constructor option' do
|
54
|
-
|
55
|
-
|
58
|
+
described_class.new(headers: { 'foo' => 'bar' }, uri: 'http://localhost:3000/')
|
59
|
+
.connection.headers['foo'].should be == 'bar'
|
56
60
|
end
|
57
61
|
|
58
62
|
it 'sets a User-Agent' do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
+
session.headers['User-Agent'].should include("Travis/#{Travis::VERSION}")
|
64
|
+
session.headers['User-Agent'].should include("Faraday/#{Faraday::VERSION}")
|
65
|
+
session.headers['User-Agent'].should include("Rack/#{Rack.version}")
|
66
|
+
session.headers['User-Agent'].should include("Ruby #{RUBY_VERSION}")
|
63
67
|
end
|
64
68
|
|
65
69
|
it 'allows adding custom info to the User-Agent' do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
session.agent_info = 'foo'
|
71
|
+
session.headers['User-Agent'].should include('foo')
|
72
|
+
session.headers['User-Agent'].should include("Travis/#{Travis::VERSION}")
|
73
|
+
session.headers['User-Agent'].should include("Faraday/#{Faraday::VERSION}")
|
74
|
+
session.headers['User-Agent'].should include("Rack/#{Rack.version}")
|
75
|
+
session.headers['User-Agent'].should include("Ruby #{RUBY_VERSION}")
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
75
|
-
describe
|
79
|
+
describe 'find_one' do
|
76
80
|
it 'finds one instance' do
|
77
|
-
repo =
|
81
|
+
repo = session.find_one(Travis::Client::Repository, 'rails/rails')
|
78
82
|
repo.should be_a(Travis::Client::Repository)
|
79
83
|
repo.slug.should be == 'rails/rails'
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
83
|
-
describe
|
87
|
+
describe 'find_many' do
|
84
88
|
it 'finds many instances' do
|
85
|
-
repos =
|
89
|
+
repos = session.find_many(Travis::Client::Repository)
|
86
90
|
repos.should be_an(Array)
|
87
91
|
repos.each { |repo| repo.should be_a(Travis::Client::Repository) }
|
88
|
-
repos.first.slug.should be ==
|
92
|
+
repos.first.slug.should be == 'pypug/django-mango'
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
92
|
-
describe
|
96
|
+
describe 'find_one_or_many' do
|
93
97
|
it 'finds one instance' do
|
94
|
-
|
95
|
-
|
98
|
+
session.access_token = 'token'
|
99
|
+
session.find_one_or_many(Travis::Client::User).should be_a(Travis::Client::User)
|
96
100
|
end
|
97
101
|
|
98
102
|
it 'finds many instances' do
|
99
|
-
|
103
|
+
session.find_one_or_many(Travis::Client::Repository).should be_an(Array)
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
103
|
-
describe
|
107
|
+
describe 'reload' do
|
104
108
|
it 'reloads an instance' do
|
105
|
-
Travis::Client::Session::FakeAPI.rails_description =
|
106
|
-
rails =
|
109
|
+
Travis::Client::Session::FakeAPI.rails_description = 'Ruby on Rails'
|
110
|
+
rails = session.find_one(Travis::Client::Repository, 'rails/rails')
|
107
111
|
rails.description.should be == 'Ruby on Rails'
|
108
112
|
Travis::Client::Session::FakeAPI.rails_description = 'Rails on the Rubies'
|
109
113
|
rails.description.should be == 'Ruby on Rails'
|
110
|
-
|
114
|
+
session.reload(rails)
|
111
115
|
rails.description.should be == 'Rails on the Rubies'
|
112
116
|
end
|
113
117
|
end
|
114
118
|
|
115
|
-
describe
|
119
|
+
describe 'get' do
|
116
120
|
it 'fetches a payload and substitutes values with entities' do
|
117
|
-
result =
|
118
|
-
result['repos'].first.slug.should be ==
|
121
|
+
result = session.get('/repos/')
|
122
|
+
result['repos'].first.slug.should be == 'pypug/django-mango'
|
119
123
|
end
|
120
124
|
end
|
121
125
|
|
122
|
-
describe
|
126
|
+
describe 'clear_cache' do
|
123
127
|
it 'resets all the entities' do
|
124
|
-
Travis::Client::Session::FakeAPI.rails_description =
|
125
|
-
rails =
|
128
|
+
Travis::Client::Session::FakeAPI.rails_description = 'Ruby on Rails'
|
129
|
+
rails = session.find_one(Travis::Client::Repository, 'rails/rails')
|
126
130
|
rails.description.should be == 'Ruby on Rails'
|
127
131
|
Travis::Client::Session::FakeAPI.rails_description = 'Rails on the Rubies'
|
128
132
|
rails.description.should be == 'Ruby on Rails'
|
129
|
-
|
133
|
+
session.clear_cache
|
130
134
|
rails.description.should be == 'Rails on the Rubies'
|
131
135
|
end
|
132
136
|
|
133
137
|
it 'keeps entries in the identity map' do
|
134
|
-
rails =
|
135
|
-
|
136
|
-
|
138
|
+
rails = session.repo('rails/rails')
|
139
|
+
session.clear_cache
|
140
|
+
session.repo('rails/rails').should be_equal(rails)
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
140
|
-
describe
|
144
|
+
describe 'clear_cache!' do
|
141
145
|
it 'resets all the entities' do
|
142
|
-
Travis::Client::Session::FakeAPI.rails_description =
|
143
|
-
rails =
|
146
|
+
Travis::Client::Session::FakeAPI.rails_description = 'Ruby on Rails'
|
147
|
+
rails = session.find_one(Travis::Client::Repository, 'rails/rails')
|
144
148
|
rails.description.should be == 'Ruby on Rails'
|
145
149
|
Travis::Client::Session::FakeAPI.rails_description = 'Rails on the Rubies'
|
146
150
|
rails.description.should be == 'Ruby on Rails'
|
147
|
-
|
151
|
+
session.clear_cache!
|
148
152
|
rails.description.should be == 'Rails on the Rubies'
|
149
153
|
end
|
150
154
|
|
151
155
|
it 'does not keep entries in the identity map' do
|
152
|
-
rails =
|
153
|
-
|
154
|
-
|
156
|
+
rails = session.repo('rails/rails')
|
157
|
+
session.clear_cache!
|
158
|
+
session.repo('rails/rails').should_not be_equal(rails)
|
155
159
|
end
|
156
160
|
end
|
157
161
|
|
158
|
-
describe
|
159
|
-
its(:session) {
|
162
|
+
describe 'session' do
|
163
|
+
its(:session) { is_expected.to eq(session) }
|
160
164
|
end
|
161
165
|
|
162
|
-
describe
|
163
|
-
its(:config) {
|
166
|
+
describe 'config' do
|
167
|
+
its(:config) { is_expected.to be == { 'host' => 'travis-ci.org' } }
|
164
168
|
end
|
165
169
|
end
|
data/spec/client/user_spec.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client::User do
|
4
6
|
# attributes :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes
|
5
|
-
subject { Travis::Client.new(:
|
6
|
-
|
7
|
-
its(:
|
8
|
-
its(:
|
9
|
-
its(:
|
10
|
-
its(:
|
11
|
-
its(:
|
12
|
-
its(:
|
7
|
+
subject { Travis::Client.new(access_token: 'token').user }
|
8
|
+
|
9
|
+
its(:login) { is_expected.to be == 'rkh' }
|
10
|
+
its(:name) { is_expected.to be == 'Konstantin Haase' }
|
11
|
+
its(:email) { is_expected.to be == 'konstantin.haase@gmail.com' }
|
12
|
+
its(:gravatar_id) { is_expected.to be == '5c2b452f6eea4a6d84c105ebd971d2a4' }
|
13
|
+
its(:locale) { is_expected.to be == 'en' }
|
14
|
+
its(:is_syncing) { is_expected.to be false }
|
15
|
+
its(:synced_at) { is_expected.to be_a(Time) }
|
13
16
|
|
14
|
-
it {
|
15
|
-
it {
|
17
|
+
it { is_expected.not_to be_syncing }
|
18
|
+
it { is_expected.to be_correct_scopes }
|
16
19
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Client do
|
4
|
-
its(:new) {
|
6
|
+
its(:new) { is_expected.to be_a(Travis::Client::Session) }
|
5
7
|
|
6
8
|
it 'accepts string argument' do
|
7
|
-
|
9
|
+
described_class.new('http://foo/').uri.should be == 'http://foo/'
|
8
10
|
end
|
9
11
|
|
10
12
|
it 'accepts options hash with string keys' do
|
11
|
-
|
13
|
+
described_class.new('uri' => 'http://foo/').uri.should be == 'http://foo/'
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'accepts options hash with symbol keys' do
|
15
|
-
|
17
|
+
described_class.new(uri: 'http://foo/').uri.should be == 'http://foo/'
|
16
18
|
end
|
17
19
|
end
|
data/spec/pro_spec.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Travis::Pro do
|
4
|
-
it {
|
5
|
-
its(:api_endpoint) {
|
6
|
+
it { is_expected.to be_a(Travis::Client::Namespace) }
|
7
|
+
its(:api_endpoint) { is_expected.to be == 'https://api.travis-ci.com/' }
|
6
8
|
|
7
9
|
it 'has a nice inspect on entities' do
|
8
|
-
Travis::Pro::Repository.find('rails/rails').inspect.should be ==
|
10
|
+
Travis::Pro::Repository.find('rails/rails').inspect.should be == '#<Travis::Pro::Repository: rails/rails>'
|
9
11
|
end
|
10
12
|
end
|