travis-akerl 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +2512 -0
- data/Rakefile +64 -0
- data/assets/cacert.pem +69 -0
- data/assets/init/c.yml +4 -0
- data/assets/init/clojure.yml +1 -0
- data/assets/init/cpp.yml +4 -0
- data/assets/init/erlang.yml +3 -0
- data/assets/init/go.yml +4 -0
- data/assets/init/groovy.yml +1 -0
- data/assets/init/haskell.yml +1 -0
- data/assets/init/java.yml +4 -0
- data/assets/init/node_js.yml +5 -0
- data/assets/init/objective-c.yml +1 -0
- data/assets/init/perl.yml +4 -0
- data/assets/init/php.yml +4 -0
- data/assets/init/python.yml +5 -0
- data/assets/init/ruby.yml +6 -0
- data/assets/init/scala.yml +4 -0
- data/assets/notifications/Travis CI.app/Contents/Info.plist +52 -0
- data/assets/notifications/Travis CI.app/Contents/MacOS/Travis CI +0 -0
- data/assets/notifications/Travis CI.app/Contents/PkgInfo +1 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/Travis CI.icns +0 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/Credits.rtf +29 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/InfoPlist.strings +0 -0
- data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
- data/assets/notifications/Travis CI.app/Contents/_CodeSignature/CodeResources +173 -0
- data/assets/notifications/Travis CI.app/Contents/embedded.provisionprofile +0 -0
- data/assets/notifications/icon.png +0 -0
- data/assets/travis.sh +163 -0
- data/assets/travis.sh.erb +64 -0
- data/bin/travis +18 -0
- data/examples/org_overview.rb +3 -0
- data/examples/pro_auth.rb +23 -0
- data/examples/stream.rb +6 -0
- data/lib/travis/auto_login.rb +3 -0
- data/lib/travis/cli/accounts.rb +31 -0
- data/lib/travis/cli/api_command.rb +182 -0
- data/lib/travis/cli/branches.rb +25 -0
- data/lib/travis/cli/cache.rb +76 -0
- data/lib/travis/cli/cancel.rb +18 -0
- data/lib/travis/cli/command.rb +422 -0
- data/lib/travis/cli/console.rb +33 -0
- data/lib/travis/cli/disable.rb +15 -0
- data/lib/travis/cli/enable.rb +31 -0
- data/lib/travis/cli/encrypt.rb +115 -0
- data/lib/travis/cli/encrypt_file.rb +140 -0
- data/lib/travis/cli/endpoint.rb +35 -0
- data/lib/travis/cli/env.rb +66 -0
- data/lib/travis/cli/help.rb +23 -0
- data/lib/travis/cli/history.rb +49 -0
- data/lib/travis/cli/init.rb +82 -0
- data/lib/travis/cli/lint.rb +49 -0
- data/lib/travis/cli/login.rb +76 -0
- data/lib/travis/cli/logout.rb +14 -0
- data/lib/travis/cli/logs.rb +65 -0
- data/lib/travis/cli/monitor.rb +111 -0
- data/lib/travis/cli/open.rb +39 -0
- data/lib/travis/cli/parser.rb +43 -0
- data/lib/travis/cli/pubkey.rb +30 -0
- data/lib/travis/cli/raw.rb +20 -0
- data/lib/travis/cli/repo_command.rb +154 -0
- data/lib/travis/cli/report.rb +101 -0
- data/lib/travis/cli/repos.rb +53 -0
- data/lib/travis/cli/requests.rb +47 -0
- data/lib/travis/cli/restart.rb +18 -0
- data/lib/travis/cli/settings.rb +79 -0
- data/lib/travis/cli/setup/anynines.rb +21 -0
- data/lib/travis/cli/setup/appfog.rb +19 -0
- data/lib/travis/cli/setup/artifacts.rb +23 -0
- data/lib/travis/cli/setup/biicode.rb +19 -0
- data/lib/travis/cli/setup/cloud_66.rb +20 -0
- data/lib/travis/cli/setup/cloud_control.rb +21 -0
- data/lib/travis/cli/setup/cloud_files.rb +20 -0
- data/lib/travis/cli/setup/cloud_foundry.rb +23 -0
- data/lib/travis/cli/setup/code_deploy.rb +55 -0
- data/lib/travis/cli/setup/deis.rb +20 -0
- data/lib/travis/cli/setup/divshot.rb +18 -0
- data/lib/travis/cli/setup/elastic_beanstalk.rb +23 -0
- data/lib/travis/cli/setup/engine_yard.rb +24 -0
- data/lib/travis/cli/setup/gcs.rb +22 -0
- data/lib/travis/cli/setup/hackage.rb +18 -0
- data/lib/travis/cli/setup/heroku.rb +20 -0
- data/lib/travis/cli/setup/modulus.rb +18 -0
- data/lib/travis/cli/setup/ninefold.rb +20 -0
- data/lib/travis/cli/setup/nodejitsu.rb +27 -0
- data/lib/travis/cli/setup/npm.rb +20 -0
- data/lib/travis/cli/setup/open_shift.rb +20 -0
- data/lib/travis/cli/setup/opsworks.rb +22 -0
- data/lib/travis/cli/setup/pypi.rb +22 -0
- data/lib/travis/cli/setup/releases.rb +35 -0
- data/lib/travis/cli/setup/ruby_gems.rb +25 -0
- data/lib/travis/cli/setup/s3.rb +25 -0
- data/lib/travis/cli/setup/sauce_connect.rb +21 -0
- data/lib/travis/cli/setup/service.rb +73 -0
- data/lib/travis/cli/setup.rb +66 -0
- data/lib/travis/cli/show.rb +57 -0
- data/lib/travis/cli/sshkey.rb +118 -0
- data/lib/travis/cli/status.rb +19 -0
- data/lib/travis/cli/sync.rb +30 -0
- data/lib/travis/cli/token.rb +14 -0
- data/lib/travis/cli/version.rb +17 -0
- data/lib/travis/cli/whatsup.rb +30 -0
- data/lib/travis/cli/whoami.rb +15 -0
- data/lib/travis/cli.rb +126 -0
- data/lib/travis/client/account.rb +56 -0
- data/lib/travis/client/artifact.rb +88 -0
- data/lib/travis/client/auto_login.rb +45 -0
- data/lib/travis/client/broadcast.rb +14 -0
- data/lib/travis/client/build.rb +47 -0
- data/lib/travis/client/cache.rb +25 -0
- data/lib/travis/client/commit.rb +28 -0
- data/lib/travis/client/entity.rb +238 -0
- data/lib/travis/client/env_var.rb +102 -0
- data/lib/travis/client/error.rb +38 -0
- data/lib/travis/client/has_uuid.rb +13 -0
- data/lib/travis/client/job.rb +61 -0
- data/lib/travis/client/lint_result.rb +25 -0
- data/lib/travis/client/listener.rb +183 -0
- data/lib/travis/client/methods.rb +104 -0
- data/lib/travis/client/namespace.rb +85 -0
- data/lib/travis/client/not_loadable.rb +13 -0
- data/lib/travis/client/repository.rb +224 -0
- data/lib/travis/client/request.rb +36 -0
- data/lib/travis/client/restartable.rb +23 -0
- data/lib/travis/client/session.rb +339 -0
- data/lib/travis/client/settings.rb +25 -0
- data/lib/travis/client/singleton_setting.rb +36 -0
- data/lib/travis/client/ssh_key.rb +11 -0
- data/lib/travis/client/states.rb +98 -0
- data/lib/travis/client/user.rb +67 -0
- data/lib/travis/client/weak_entity.rb +26 -0
- data/lib/travis/client.rb +38 -0
- data/lib/travis/pro/auto_login.rb +3 -0
- data/lib/travis/pro.rb +5 -0
- data/lib/travis/tools/assets.rb +21 -0
- data/lib/travis/tools/completion.rb +54 -0
- data/lib/travis/tools/formatter.rb +50 -0
- data/lib/travis/tools/github.rb +293 -0
- data/lib/travis/tools/notification.rb +69 -0
- data/lib/travis/tools/safe_string.rb +22 -0
- data/lib/travis/tools/ssl_key.rb +48 -0
- data/lib/travis/tools/system.rb +88 -0
- data/lib/travis/version.rb +3 -0
- data/lib/travis.rb +8 -0
- data/spec/cli/api_command_spec.rb +38 -0
- data/spec/cli/cancel_spec.rb +15 -0
- data/spec/cli/encrypt_spec.rb +49 -0
- data/spec/cli/endpoint_spec.rb +39 -0
- data/spec/cli/help_spec.rb +33 -0
- data/spec/cli/history_spec.rb +38 -0
- data/spec/cli/init_spec.rb +227 -0
- data/spec/cli/login_spec.rb +13 -0
- data/spec/cli/logs_spec.rb +8 -0
- data/spec/cli/open_spec.rb +33 -0
- data/spec/cli/repo_command_spec.rb +25 -0
- data/spec/cli/restart_spec.rb +15 -0
- data/spec/cli/setup_spec.rb +5 -0
- data/spec/cli/show_spec.rb +9 -0
- data/spec/cli/status_spec.rb +28 -0
- data/spec/cli/token_spec.rb +22 -0
- data/spec/cli/version_spec.rb +18 -0
- data/spec/cli/whoami_spec.rb +34 -0
- data/spec/client/account_spec.rb +32 -0
- data/spec/client/auto_login_spec.rb +25 -0
- data/spec/client/broadcast_spec.rb +10 -0
- data/spec/client/build_spec.rb +31 -0
- data/spec/client/commit_spec.rb +22 -0
- data/spec/client/job_spec.rb +30 -0
- data/spec/client/methods_spec.rb +15 -0
- data/spec/client/namespace_spec.rb +19 -0
- data/spec/client/repository_spec.rb +39 -0
- data/spec/client/session_spec.rb +165 -0
- data/spec/client/user_spec.rb +16 -0
- data/spec/client_spec.rb +17 -0
- data/spec/pro_spec.rb +10 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/fake_api.rb +731 -0
- data/spec/support/fake_github.rb +24 -0
- data/spec/support/fake_travis_config.yml +14 -0
- data/spec/support/helpers.rb +45 -0
- data/spec/travis_spec.rb +10 -0
- data/travis.gemspec +371 -0
- metadata +534 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Account do
|
|
4
|
+
context "from all accounts" do
|
|
5
|
+
let(:session) { Travis::Client.new }
|
|
6
|
+
subject { session.accounts.first }
|
|
7
|
+
its(:name) { should be == 'Konstantin Haase' }
|
|
8
|
+
its(:login) { should be == 'rkh' }
|
|
9
|
+
its(:type) { should be == 'user' }
|
|
10
|
+
its(:repos_count) { should be == 200 }
|
|
11
|
+
its(:inspect) { should be == "#<Travis::Client::Account: rkh>" }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "known account" do
|
|
15
|
+
let(:session) { Travis::Client.new }
|
|
16
|
+
subject { session.account('rkh') }
|
|
17
|
+
its(:name) { should be == 'Konstantin Haase' }
|
|
18
|
+
its(:login) { should be == 'rkh' }
|
|
19
|
+
its(:type) { should be == 'user' }
|
|
20
|
+
its(:repos_count) { should be == 200 }
|
|
21
|
+
its(:inspect) { should be == "#<Travis::Client::Account: rkh>" }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "known account" do
|
|
25
|
+
let(:session) { Travis::Client.new }
|
|
26
|
+
subject { session.account('foo') }
|
|
27
|
+
its(:name) { should be_nil }
|
|
28
|
+
its(:login) { should be == 'foo' }
|
|
29
|
+
its(:type) { should be_nil }
|
|
30
|
+
its(:inspect) { should be == "#<Travis::Client::Account: foo>" }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'travis/client/auto_login'
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe Travis::Client::AutoLogin do
|
|
5
|
+
let(:auto_login_with_token) { Travis::Client::AutoLogin.new(Travis::Client.new, { config_file: travis_config }) }
|
|
6
|
+
let(:auto_login_without_token) { Travis::Client::AutoLogin.new(Travis::Client.new) }
|
|
7
|
+
let(:travis_config) { File.expand_path("../support/fake_travis_config.yml", File.dirname(__FILE__)) }
|
|
8
|
+
|
|
9
|
+
context "authenticate" do
|
|
10
|
+
context "when user has a token in cli config" do
|
|
11
|
+
it "does not call Tools::Github#with_token" do
|
|
12
|
+
expect(Travis::Tools::Github.any_instance).to_not receive(:with_token)
|
|
13
|
+
auto_login_with_token.authenticate
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "when user does not have a token in cli config" do
|
|
18
|
+
before { auto_login_without_token.github.stub(:with_token).and_return(true) }
|
|
19
|
+
it "calls Tools::Github#with_token" do
|
|
20
|
+
expect(auto_login_without_token.github).to receive(:with_token)
|
|
21
|
+
auto_login_without_token.authenticate
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Build do
|
|
4
|
+
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
|
+
|
|
17
|
+
it { should be == subject.repository.last_build }
|
|
18
|
+
|
|
19
|
+
it { should_not be_pending }
|
|
20
|
+
it { should be_started }
|
|
21
|
+
it { should be_finished }
|
|
22
|
+
it { should_not be_passed }
|
|
23
|
+
it { should_not be_errored }
|
|
24
|
+
it { should be_failed }
|
|
25
|
+
it { should_not be_canceled }
|
|
26
|
+
it { should be_created }
|
|
27
|
+
it { should be_red }
|
|
28
|
+
it { should_not be_green }
|
|
29
|
+
it { should_not be_yellow }
|
|
30
|
+
it { should be_unsuccessful }
|
|
31
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Build do
|
|
4
|
+
let(:session) { Travis::Client.new }
|
|
5
|
+
subject { session.build(4125095).commit }
|
|
6
|
+
|
|
7
|
+
its(:sha) { should be == 'a0265b98f16c6e33be32aa3f57231d1189302400' }
|
|
8
|
+
its(:short_sha) { should be == 'a0265b9' }
|
|
9
|
+
its(:branch) { should be == 'master' }
|
|
10
|
+
its(:message) { should be == 'Associaton -> Association' }
|
|
11
|
+
its(:committed_at) { should be_a(Time) }
|
|
12
|
+
its(:author_name) { should be == 'Steve Klabnik' }
|
|
13
|
+
its(:author_email) { should be == 'steve@steveklabnik.com' }
|
|
14
|
+
its(:committer_name) { should be == 'Steve Klabnik' }
|
|
15
|
+
its(:committer_email) { should be == 'steve@steveklabnik.com' }
|
|
16
|
+
its(:compare_url) { should be == 'https://github.com/rails/rails/compare/6581d798e830...a0265b98f16c' }
|
|
17
|
+
its(:subject) { should be == 'Associaton -> Association' }
|
|
18
|
+
|
|
19
|
+
specify "with missing data" do
|
|
20
|
+
session.load("commit" => { "id" => 12 })['commit'].subject.should be_empty
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Job do
|
|
4
|
+
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
|
+
|
|
16
|
+
it { should be == subject.build.jobs[1] }
|
|
17
|
+
|
|
18
|
+
it { should_not be_pending }
|
|
19
|
+
it { should be_started }
|
|
20
|
+
it { should be_finished }
|
|
21
|
+
it { should be_passed }
|
|
22
|
+
it { should_not be_errored }
|
|
23
|
+
it { should_not be_failed }
|
|
24
|
+
it { should_not be_canceled }
|
|
25
|
+
it { should be_created }
|
|
26
|
+
it { should_not be_red }
|
|
27
|
+
it { should be_green }
|
|
28
|
+
it { should_not be_yellow }
|
|
29
|
+
it { should_not be_unsuccessful }
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Methods do
|
|
4
|
+
let(:session) { Travis::Client.new }
|
|
5
|
+
subject { OpenStruct.new(:session => session).extend(Travis::Client::Methods) }
|
|
6
|
+
before { subject.access_token = 'token' }
|
|
7
|
+
|
|
8
|
+
its(:api_endpoint) { should be == 'https://api.travis-ci.org/' }
|
|
9
|
+
its(:repos) { should be == session.find_many(Travis::Client::Repository) }
|
|
10
|
+
its(:user) { should be == session.find_one(Travis::Client::User) }
|
|
11
|
+
|
|
12
|
+
it 'fetches a single repo' do
|
|
13
|
+
subject.repo(891).slug.should be == 'rails/rails'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Namespace do
|
|
4
|
+
it { should be_a(Travis::Client::Methods) }
|
|
5
|
+
|
|
6
|
+
it 'creates a dummy for repos' do
|
|
7
|
+
repo = subject::Repository
|
|
8
|
+
repo.find_one('rails/rails').should be_a(Travis::Client::Repository)
|
|
9
|
+
repo.find_many.should be_an(Array)
|
|
10
|
+
repo.current.should be == repo.find_many
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'creates a dummy for user' do
|
|
14
|
+
subject.access_token = 'token'
|
|
15
|
+
user = subject::User
|
|
16
|
+
user.find_one.should be_a(Travis::Client::User)
|
|
17
|
+
user.current.should be == user.find_one
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Repository do
|
|
4
|
+
let(:session) { Travis::Client.new }
|
|
5
|
+
subject { session.repo('rails/rails') }
|
|
6
|
+
|
|
7
|
+
its(:slug) { should be == 'rails/rails' }
|
|
8
|
+
its(:description) { should_not be_empty }
|
|
9
|
+
its(:last_build_id) { should be == 4125095 }
|
|
10
|
+
its(:last_build_number) { should be == '6180' }
|
|
11
|
+
its(:last_build_state) { should be == 'failed' }
|
|
12
|
+
its(:last_build_duration) { should be == 5019 }
|
|
13
|
+
its(:last_build_started_at) { should be_a(Time) }
|
|
14
|
+
its(:last_build_finished_at) { should be_nil }
|
|
15
|
+
its(:inspect) { should be == "#<Travis::Client::Repository: rails/rails>" }
|
|
16
|
+
its(:key) { should be_a(Travis::Client::Repository::Key) }
|
|
17
|
+
its(:last_build) { should be_a(Travis::Client::Build) }
|
|
18
|
+
its(:color) { should be == 'red' }
|
|
19
|
+
its(:github_language) { should be == 'Ruby' }
|
|
20
|
+
its(:owner_name) { should be == 'rails' }
|
|
21
|
+
its(:owner) { should be == session.account("rails") }
|
|
22
|
+
|
|
23
|
+
it { should_not be_pending }
|
|
24
|
+
it { should be_started }
|
|
25
|
+
it { should be_finished }
|
|
26
|
+
it { should_not be_passed }
|
|
27
|
+
it { should_not be_errored }
|
|
28
|
+
it { should be_failed }
|
|
29
|
+
it { should_not be_canceled }
|
|
30
|
+
it { should be_created }
|
|
31
|
+
it { should be_red }
|
|
32
|
+
it { should_not be_green }
|
|
33
|
+
it { should_not be_yellow }
|
|
34
|
+
it { should be_unsuccessful }
|
|
35
|
+
|
|
36
|
+
it 'should expose the pubkey fingerprint' do
|
|
37
|
+
subject.public_key.fingerprint.should be == 'foobar'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::Session do
|
|
4
|
+
it { should be_a(Travis::Client::Methods) }
|
|
5
|
+
|
|
6
|
+
describe "uri" do
|
|
7
|
+
its(:uri) { should be == "https://api.travis-ci.org/" }
|
|
8
|
+
|
|
9
|
+
it 'can be set as argument' do
|
|
10
|
+
Travis::Client::Session.new('http://foo/').uri.should be == 'http://foo/'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'can be set as hash argument' do
|
|
14
|
+
Travis::Client::Session.new(:uri => 'http://foo/').uri.should be == 'http://foo/'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "access_token" do
|
|
19
|
+
its(:access_token) { should be_nil }
|
|
20
|
+
|
|
21
|
+
it 'gives authenticated access if set' do
|
|
22
|
+
subject.access_token = 'token'
|
|
23
|
+
subject.user.login.should be == 'rkh'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'raises if token is not set' do
|
|
27
|
+
expect { subject.user.login }.to raise_error(Travis::Client::Error)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "connection" do
|
|
32
|
+
its(:connection) { should be_a(Faraday::Connection) }
|
|
33
|
+
|
|
34
|
+
it 'creates a new connection when changing the uri' do
|
|
35
|
+
old_connection = subject.connection
|
|
36
|
+
subject.uri = 'http://localhost:3000'
|
|
37
|
+
subject.connection.should_not be == old_connection
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "headers" do
|
|
42
|
+
it 'propagates headers to connection headers' do
|
|
43
|
+
subject.headers['foo'] = 'bar'
|
|
44
|
+
subject.connection.headers.should include('foo')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'propagates headers to new connections' do
|
|
48
|
+
subject.headers['foo'] = 'bar'
|
|
49
|
+
subject.connection = Faraday::Connection.new
|
|
50
|
+
subject.connection.headers.should include('foo')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'is possible to set headers as constructor option' do
|
|
54
|
+
Travis::Client::Session.new(:headers => {'foo' => 'bar'}, :uri => 'http://localhost:3000/').
|
|
55
|
+
connection.headers['foo'].should be == 'bar'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'sets a User-Agent' do
|
|
59
|
+
subject.headers['User-Agent'].should include("Travis/#{Travis::VERSION}")
|
|
60
|
+
subject.headers['User-Agent'].should include("Faraday/#{Faraday::VERSION}")
|
|
61
|
+
subject.headers['User-Agent'].should include("Rack/#{Rack.version}")
|
|
62
|
+
subject.headers['User-Agent'].should include("Ruby #{RUBY_VERSION}")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'allows adding custom infos to the User-Agent' do
|
|
66
|
+
subject.agent_info = "foo"
|
|
67
|
+
subject.headers['User-Agent'].should include("foo")
|
|
68
|
+
subject.headers['User-Agent'].should include("Travis/#{Travis::VERSION}")
|
|
69
|
+
subject.headers['User-Agent'].should include("Faraday/#{Faraday::VERSION}")
|
|
70
|
+
subject.headers['User-Agent'].should include("Rack/#{Rack.version}")
|
|
71
|
+
subject.headers['User-Agent'].should include("Ruby #{RUBY_VERSION}")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe "find_one" do
|
|
76
|
+
it 'finds one instance' do
|
|
77
|
+
repo = subject.find_one(Travis::Client::Repository, 'rails/rails')
|
|
78
|
+
repo.should be_a(Travis::Client::Repository)
|
|
79
|
+
repo.slug.should be == 'rails/rails'
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "find_many" do
|
|
84
|
+
it 'finds many instances' do
|
|
85
|
+
repos = subject.find_many(Travis::Client::Repository)
|
|
86
|
+
repos.should be_an(Array)
|
|
87
|
+
repos.each { |repo| repo.should be_a(Travis::Client::Repository) }
|
|
88
|
+
repos.first.slug.should be == "pypug/django-mango"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe "find_one_or_many" do
|
|
93
|
+
it 'finds one instance' do
|
|
94
|
+
subject.access_token = 'token'
|
|
95
|
+
subject.find_one_or_many(Travis::Client::User).should be_a(Travis::Client::User)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'finds many instances' do
|
|
99
|
+
subject.find_one_or_many(Travis::Client::Repository).should be_an(Array)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe "reload" do
|
|
104
|
+
it 'reloads an instance' do
|
|
105
|
+
Travis::Client::Session::FakeAPI.rails_description = "Ruby on Rails"
|
|
106
|
+
rails = subject.find_one(Travis::Client::Repository, 'rails/rails')
|
|
107
|
+
rails.description.should be == 'Ruby on Rails'
|
|
108
|
+
Travis::Client::Session::FakeAPI.rails_description = 'Rails on the Rubies'
|
|
109
|
+
rails.description.should be == 'Ruby on Rails'
|
|
110
|
+
subject.reload(rails)
|
|
111
|
+
rails.description.should be == 'Rails on the Rubies'
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe "get" do
|
|
116
|
+
it 'fetches a payload and substitutes values with entities' do
|
|
117
|
+
result = subject.get('/repos/')
|
|
118
|
+
result['repos'].first.slug.should be == "pypug/django-mango"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe "clear_cache" do
|
|
123
|
+
it 'resets all the entities' do
|
|
124
|
+
Travis::Client::Session::FakeAPI.rails_description = "Ruby on Rails"
|
|
125
|
+
rails = subject.find_one(Travis::Client::Repository, 'rails/rails')
|
|
126
|
+
rails.description.should be == 'Ruby on Rails'
|
|
127
|
+
Travis::Client::Session::FakeAPI.rails_description = 'Rails on the Rubies'
|
|
128
|
+
rails.description.should be == 'Ruby on Rails'
|
|
129
|
+
subject.clear_cache
|
|
130
|
+
rails.description.should be == 'Rails on the Rubies'
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'keeps entries in the identity map' do
|
|
134
|
+
rails = subject.repo('rails/rails')
|
|
135
|
+
subject.clear_cache
|
|
136
|
+
subject.repo('rails/rails').should be_equal(rails)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe "clear_cache!" do
|
|
141
|
+
it 'resets all the entities' do
|
|
142
|
+
Travis::Client::Session::FakeAPI.rails_description = "Ruby on Rails"
|
|
143
|
+
rails = subject.find_one(Travis::Client::Repository, 'rails/rails')
|
|
144
|
+
rails.description.should be == 'Ruby on Rails'
|
|
145
|
+
Travis::Client::Session::FakeAPI.rails_description = 'Rails on the Rubies'
|
|
146
|
+
rails.description.should be == 'Ruby on Rails'
|
|
147
|
+
subject.clear_cache!
|
|
148
|
+
rails.description.should be == 'Rails on the Rubies'
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'does not keep entries in the identity map' do
|
|
152
|
+
rails = subject.repo('rails/rails')
|
|
153
|
+
subject.clear_cache!
|
|
154
|
+
subject.repo('rails/rails').should_not be_equal(rails)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe "session" do
|
|
159
|
+
its(:session) { should eq(subject) }
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
describe "config" do
|
|
163
|
+
its(:config) { should be == {"host" => "travis-ci.org"}}
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client::User do
|
|
4
|
+
# attributes :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes
|
|
5
|
+
subject { Travis::Client.new(:access_token => 'token').user }
|
|
6
|
+
its(:login) { should be == 'rkh' }
|
|
7
|
+
its(:name) { should be == 'Konstantin Haase' }
|
|
8
|
+
its(:email) { should be == 'konstantin.haase@gmail.com' }
|
|
9
|
+
its(:gravatar_id) { should be == '5c2b452f6eea4a6d84c105ebd971d2a4' }
|
|
10
|
+
its(:locale) { should be == 'en' }
|
|
11
|
+
its(:is_syncing) { should be_false }
|
|
12
|
+
its(:synced_at) { should be_a(Time) }
|
|
13
|
+
|
|
14
|
+
it { should_not be_syncing }
|
|
15
|
+
it { should be_correct_scopes }
|
|
16
|
+
end
|
data/spec/client_spec.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Client do
|
|
4
|
+
its(:new) { should be_a(Travis::Client::Session) }
|
|
5
|
+
|
|
6
|
+
it 'accepts string argument' do
|
|
7
|
+
Travis::Client.new('http://foo/').uri.should be == 'http://foo/'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'accepts options hash with string keys' do
|
|
11
|
+
Travis::Client.new('uri' => 'http://foo/').uri.should be == 'http://foo/'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'accepts options hash with symbol keys' do
|
|
15
|
+
Travis::Client.new(:uri => 'http://foo/').uri.should be == 'http://foo/'
|
|
16
|
+
end
|
|
17
|
+
end
|
data/spec/pro_spec.rb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Travis::Pro do
|
|
4
|
+
it { should be_a(Travis::Client::Namespace) }
|
|
5
|
+
its(:api_endpoint) { should be == 'https://api.travis-ci.com/' }
|
|
6
|
+
|
|
7
|
+
it 'has a nice inspect on entities' do
|
|
8
|
+
Travis::Pro::Repository.find('rails/rails').inspect.should be == "#<Travis::Pro::Repository: rails/rails>"
|
|
9
|
+
end
|
|
10
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'support/fake_api'
|
|
2
|
+
require 'support/fake_github'
|
|
3
|
+
require 'support/helpers'
|
|
4
|
+
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
require 'travis'
|
|
7
|
+
require 'highline'
|
|
8
|
+
require 'tmpdir'
|
|
9
|
+
|
|
10
|
+
temp_dir = nil
|
|
11
|
+
|
|
12
|
+
HighLine.use_color = false
|
|
13
|
+
HighLine.define_singleton_method(:use_color=) { |_| }
|
|
14
|
+
|
|
15
|
+
RSpec.configure do |c|
|
|
16
|
+
c.include Helpers
|
|
17
|
+
|
|
18
|
+
c.before do
|
|
19
|
+
temp_dir = File.expand_path('travis-spec', Dir.tmpdir)
|
|
20
|
+
FileUtils.rm_rf(temp_dir)
|
|
21
|
+
FileUtils.mkdir_p(temp_dir)
|
|
22
|
+
ENV.delete_if { |k,v| k.start_with? "TRAVIS_" }
|
|
23
|
+
ENV['TRAVIS_CONFIG_PATH'] = File.expand_path('travis', temp_dir)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
c.after do
|
|
27
|
+
FileUtils.rm_rf(temp_dir)
|
|
28
|
+
end
|
|
29
|
+
end
|