travis-async-listener 1.8.3

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.
Files changed (184) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +2486 -0
  4. data/Rakefile +63 -0
  5. data/assets/cacert.pem +69 -0
  6. data/assets/init/c.yml +4 -0
  7. data/assets/init/clojure.yml +1 -0
  8. data/assets/init/cpp.yml +4 -0
  9. data/assets/init/erlang.yml +3 -0
  10. data/assets/init/go.yml +4 -0
  11. data/assets/init/groovy.yml +1 -0
  12. data/assets/init/haskell.yml +1 -0
  13. data/assets/init/java.yml +4 -0
  14. data/assets/init/node_js.yml +4 -0
  15. data/assets/init/objective-c.yml +1 -0
  16. data/assets/init/perl.yml +4 -0
  17. data/assets/init/php.yml +4 -0
  18. data/assets/init/python.yml +5 -0
  19. data/assets/init/ruby.yml +6 -0
  20. data/assets/init/scala.yml +4 -0
  21. data/assets/notifications/Travis CI.app/Contents/Info.plist +52 -0
  22. data/assets/notifications/Travis CI.app/Contents/MacOS/Travis CI +0 -0
  23. data/assets/notifications/Travis CI.app/Contents/PkgInfo +1 -0
  24. data/assets/notifications/Travis CI.app/Contents/Resources/Travis CI.icns +0 -0
  25. data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/Credits.rtf +29 -0
  26. data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/InfoPlist.strings +0 -0
  27. data/assets/notifications/Travis CI.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
  28. data/assets/notifications/Travis CI.app/Contents/_CodeSignature/CodeResources +173 -0
  29. data/assets/notifications/Travis CI.app/Contents/embedded.provisionprofile +0 -0
  30. data/assets/notifications/icon.png +0 -0
  31. data/assets/travis.sh +163 -0
  32. data/assets/travis.sh.erb +64 -0
  33. data/bin/travis +18 -0
  34. data/examples/org_overview.rb +3 -0
  35. data/examples/pro_auth.rb +23 -0
  36. data/examples/stream.rb +6 -0
  37. data/lib/travis.rb +8 -0
  38. data/lib/travis/auto_login.rb +3 -0
  39. data/lib/travis/cli.rb +126 -0
  40. data/lib/travis/cli/accounts.rb +31 -0
  41. data/lib/travis/cli/api_command.rb +180 -0
  42. data/lib/travis/cli/branches.rb +25 -0
  43. data/lib/travis/cli/cache.rb +76 -0
  44. data/lib/travis/cli/cancel.rb +18 -0
  45. data/lib/travis/cli/command.rb +422 -0
  46. data/lib/travis/cli/console.rb +31 -0
  47. data/lib/travis/cli/disable.rb +15 -0
  48. data/lib/travis/cli/enable.rb +31 -0
  49. data/lib/travis/cli/encrypt.rb +108 -0
  50. data/lib/travis/cli/encrypt_file.rb +140 -0
  51. data/lib/travis/cli/endpoint.rb +35 -0
  52. data/lib/travis/cli/env.rb +66 -0
  53. data/lib/travis/cli/help.rb +23 -0
  54. data/lib/travis/cli/history.rb +49 -0
  55. data/lib/travis/cli/init.rb +82 -0
  56. data/lib/travis/cli/lint.rb +49 -0
  57. data/lib/travis/cli/login.rb +76 -0
  58. data/lib/travis/cli/logout.rb +14 -0
  59. data/lib/travis/cli/logs.rb +65 -0
  60. data/lib/travis/cli/monitor.rb +110 -0
  61. data/lib/travis/cli/open.rb +39 -0
  62. data/lib/travis/cli/parser.rb +43 -0
  63. data/lib/travis/cli/pubkey.rb +30 -0
  64. data/lib/travis/cli/raw.rb +20 -0
  65. data/lib/travis/cli/repo_command.rb +154 -0
  66. data/lib/travis/cli/report.rb +101 -0
  67. data/lib/travis/cli/repos.rb +53 -0
  68. data/lib/travis/cli/requests.rb +47 -0
  69. data/lib/travis/cli/restart.rb +18 -0
  70. data/lib/travis/cli/settings.rb +77 -0
  71. data/lib/travis/cli/setup.rb +66 -0
  72. data/lib/travis/cli/setup/anynines.rb +21 -0
  73. data/lib/travis/cli/setup/appfog.rb +19 -0
  74. data/lib/travis/cli/setup/artifacts.rb +23 -0
  75. data/lib/travis/cli/setup/biicode.rb +19 -0
  76. data/lib/travis/cli/setup/cloud_66.rb +20 -0
  77. data/lib/travis/cli/setup/cloud_control.rb +21 -0
  78. data/lib/travis/cli/setup/cloud_files.rb +20 -0
  79. data/lib/travis/cli/setup/cloud_foundry.rb +23 -0
  80. data/lib/travis/cli/setup/code_deploy.rb +55 -0
  81. data/lib/travis/cli/setup/deis.rb +20 -0
  82. data/lib/travis/cli/setup/divshot.rb +18 -0
  83. data/lib/travis/cli/setup/elastic_beanstalk.rb +23 -0
  84. data/lib/travis/cli/setup/engine_yard.rb +24 -0
  85. data/lib/travis/cli/setup/gcs.rb +22 -0
  86. data/lib/travis/cli/setup/hackage.rb +18 -0
  87. data/lib/travis/cli/setup/heroku.rb +20 -0
  88. data/lib/travis/cli/setup/modulus.rb +18 -0
  89. data/lib/travis/cli/setup/ninefold.rb +20 -0
  90. data/lib/travis/cli/setup/nodejitsu.rb +27 -0
  91. data/lib/travis/cli/setup/npm.rb +20 -0
  92. data/lib/travis/cli/setup/open_shift.rb +20 -0
  93. data/lib/travis/cli/setup/opsworks.rb +22 -0
  94. data/lib/travis/cli/setup/pypi.rb +22 -0
  95. data/lib/travis/cli/setup/releases.rb +35 -0
  96. data/lib/travis/cli/setup/ruby_gems.rb +25 -0
  97. data/lib/travis/cli/setup/s3.rb +25 -0
  98. data/lib/travis/cli/setup/sauce_connect.rb +21 -0
  99. data/lib/travis/cli/setup/service.rb +73 -0
  100. data/lib/travis/cli/show.rb +69 -0
  101. data/lib/travis/cli/sshkey.rb +118 -0
  102. data/lib/travis/cli/status.rb +19 -0
  103. data/lib/travis/cli/sync.rb +30 -0
  104. data/lib/travis/cli/token.rb +14 -0
  105. data/lib/travis/cli/version.rb +17 -0
  106. data/lib/travis/cli/whatsup.rb +30 -0
  107. data/lib/travis/cli/whoami.rb +15 -0
  108. data/lib/travis/client.rb +39 -0
  109. data/lib/travis/client/account.rb +56 -0
  110. data/lib/travis/client/annotation.rb +21 -0
  111. data/lib/travis/client/artifact.rb +88 -0
  112. data/lib/travis/client/auto_login.rb +45 -0
  113. data/lib/travis/client/broadcast.rb +14 -0
  114. data/lib/travis/client/build.rb +47 -0
  115. data/lib/travis/client/cache.rb +25 -0
  116. data/lib/travis/client/commit.rb +28 -0
  117. data/lib/travis/client/entity.rb +238 -0
  118. data/lib/travis/client/env_var.rb +102 -0
  119. data/lib/travis/client/error.rb +38 -0
  120. data/lib/travis/client/has_uuid.rb +13 -0
  121. data/lib/travis/client/job.rb +61 -0
  122. data/lib/travis/client/lint_result.rb +25 -0
  123. data/lib/travis/client/listener.rb +184 -0
  124. data/lib/travis/client/methods.rb +104 -0
  125. data/lib/travis/client/namespace.rb +85 -0
  126. data/lib/travis/client/not_loadable.rb +13 -0
  127. data/lib/travis/client/repository.rb +224 -0
  128. data/lib/travis/client/request.rb +36 -0
  129. data/lib/travis/client/restartable.rb +23 -0
  130. data/lib/travis/client/session.rb +339 -0
  131. data/lib/travis/client/settings.rb +25 -0
  132. data/lib/travis/client/singleton_setting.rb +36 -0
  133. data/lib/travis/client/ssh_key.rb +11 -0
  134. data/lib/travis/client/states.rb +98 -0
  135. data/lib/travis/client/user.rb +67 -0
  136. data/lib/travis/client/weak_entity.rb +26 -0
  137. data/lib/travis/pro.rb +5 -0
  138. data/lib/travis/pro/auto_login.rb +3 -0
  139. data/lib/travis/tools/assets.rb +21 -0
  140. data/lib/travis/tools/completion.rb +54 -0
  141. data/lib/travis/tools/formatter.rb +50 -0
  142. data/lib/travis/tools/github.rb +279 -0
  143. data/lib/travis/tools/notification.rb +69 -0
  144. data/lib/travis/tools/safe_string.rb +22 -0
  145. data/lib/travis/tools/ssl_key.rb +48 -0
  146. data/lib/travis/tools/system.rb +88 -0
  147. data/lib/travis/version.rb +3 -0
  148. data/spec/cli/cancel_spec.rb +15 -0
  149. data/spec/cli/encrypt_spec.rb +43 -0
  150. data/spec/cli/endpoint_spec.rb +34 -0
  151. data/spec/cli/help_spec.rb +33 -0
  152. data/spec/cli/history_spec.rb +38 -0
  153. data/spec/cli/init_spec.rb +226 -0
  154. data/spec/cli/login_spec.rb +13 -0
  155. data/spec/cli/logs_spec.rb +8 -0
  156. data/spec/cli/open_spec.rb +33 -0
  157. data/spec/cli/repo_command_spec.rb +25 -0
  158. data/spec/cli/restart_spec.rb +15 -0
  159. data/spec/cli/setup_spec.rb +5 -0
  160. data/spec/cli/show_spec.rb +9 -0
  161. data/spec/cli/status_spec.rb +28 -0
  162. data/spec/cli/token_spec.rb +22 -0
  163. data/spec/cli/version_spec.rb +18 -0
  164. data/spec/cli/whoami_spec.rb +34 -0
  165. data/spec/client/account_spec.rb +32 -0
  166. data/spec/client/annotation_spec.rb +14 -0
  167. data/spec/client/broadcast_spec.rb +10 -0
  168. data/spec/client/build_spec.rb +31 -0
  169. data/spec/client/commit_spec.rb +22 -0
  170. data/spec/client/job_spec.rb +30 -0
  171. data/spec/client/methods_spec.rb +15 -0
  172. data/spec/client/namespace_spec.rb +19 -0
  173. data/spec/client/repository_spec.rb +39 -0
  174. data/spec/client/session_spec.rb +165 -0
  175. data/spec/client/user_spec.rb +16 -0
  176. data/spec/client_spec.rb +17 -0
  177. data/spec/pro_spec.rb +10 -0
  178. data/spec/spec_helper.rb +29 -0
  179. data/spec/support/fake_api.rb +738 -0
  180. data/spec/support/fake_github.rb +24 -0
  181. data/spec/support/helpers.rb +45 -0
  182. data/spec/travis_spec.rb +10 -0
  183. data/travis.gemspec +323 -0
  184. metadata +489 -0
@@ -0,0 +1,69 @@
1
+ require "travis"
2
+ require "travis/tools/system"
3
+ require "travis/tools/assets"
4
+ require "cgi"
5
+
6
+ module Travis
7
+ module Tools
8
+ module Notification
9
+ extend self
10
+ DEFAULT = [:osx, :growl, :libnotify]
11
+ ICON = Assets['notifications/icon.png']
12
+
13
+ def new(*list)
14
+ list.concat(DEFAULT) if list.empty?
15
+ notification = list.map { |n| get(n) }.detect { |n| n.available? }
16
+ raise ArgumentError, "no notification system found (looked for #{list.join(", ")})" unless notification
17
+ notification
18
+ end
19
+
20
+ def get(name)
21
+ const = constants.detect { |c| c.to_s[/[^:]+$/].downcase == name.to_s }
22
+ raise ArgumentError, "unknown notifications type %p" % name unless const
23
+ const_get(const).new
24
+ end
25
+
26
+ class Dummy
27
+ BIN_PATH = Assets['Travis CI.app/Contents/MacOS/Travis CI']
28
+ def notify(title, body)
29
+ end
30
+
31
+ def available?
32
+ true
33
+ end
34
+ end
35
+
36
+ class OSX
37
+ BIN_PATH = Assets["notifications/Travis CI.app/Contents/MacOS/Travis CI"]
38
+
39
+ def notify(title, body)
40
+ system BIN_PATH, '-message', body.to_s, '-title', title.to_s, '-sender', 'org.travis-ci.Travis-CI'
41
+ end
42
+
43
+ def available?
44
+ System.mac? and System.recent_version?(System.os_version.to_s, '10.8') and System.running? "NotificationCenter"
45
+ end
46
+ end
47
+
48
+ class Growl
49
+ def notify(title, body)
50
+ system 'growlnotify', '-n', 'Travis', '--image', ICON, '-m', body, title
51
+ end
52
+
53
+ def available?
54
+ System.has? 'growlnotify' and System.running? "Growl"
55
+ end
56
+ end
57
+
58
+ class LibNotify
59
+ def notify(title, body)
60
+ system 'notify-send', '--expire-time=10000', '-h', 'int:transient:1', '-i', ICON, title, CGI.escapeHTML(body)
61
+ end
62
+
63
+ def available?
64
+ System.has? 'notify-send'
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,22 @@
1
+ module Travis
2
+ module Tools
3
+ module SafeString
4
+ extend self
5
+
6
+ def encoded(string)
7
+ return string unless string.respond_to? :encode
8
+ string.encode 'utf-8'
9
+ rescue Encoding::UndefinedConversionError
10
+ string.force_encoding 'utf-8'
11
+ end
12
+
13
+ def colorized(string)
14
+ encoded(string).gsub(/[^[:print:]\e\n]/, '')
15
+ end
16
+
17
+ def clean(string)
18
+ colorized(string).gsub(/\e[^m]+m/, '')
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,48 @@
1
+ require 'openssl'
2
+ require 'base64'
3
+
4
+ module Travis
5
+ module Tools
6
+ module SSLKey
7
+ extend self
8
+
9
+ def generate_rsa(size = 2048)
10
+ OpenSSL::PKey::RSA.generate(size)
11
+ end
12
+
13
+ def public_rsa_key(string)
14
+ @to_rsa ||= OpenSSL::PKey::RSA.new(string)
15
+ rescue OpenSSL::PKey::RSAError
16
+ public_key = string.gsub('RSA PUBLIC KEY', 'PUBLIC KEY')
17
+ @to_rsa = OpenSSL::PKey::RSA.new(public_key)
18
+ end
19
+
20
+ def has_passphrase?(key)
21
+ OpenSSL::PKey::RSA.new(key, key)
22
+ false
23
+ rescue OpenSSL::PKey::RSAError
24
+ true
25
+ end
26
+
27
+ def remove_passphrase(key, passphrase)
28
+ OpenSSL::PKey::RSA.new(key, passphrase).to_s
29
+ rescue OpenSSL::PKey::RSAError
30
+ false
31
+ end
32
+
33
+ def rsa_ssh(key)
34
+ ['ssh-rsa ', "\0\0\0\assh-rsa#{sized_bytes(key.e)}#{sized_bytes(key.n)}"].pack('a*m').gsub("\n", '')
35
+ end
36
+
37
+ def sized_bytes(value)
38
+ bytes = to_byte_array(value.to_i)
39
+ [bytes.size, *bytes].pack('NC*')
40
+ end
41
+
42
+ def to_byte_array(num, *significant)
43
+ return significant if num.between?(-1, 0) and significant[0][7] == num[7]
44
+ to_byte_array(*num.divmod(256)) + significant
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,88 @@
1
+ module Travis
2
+ module Tools
3
+ module System
4
+ extend self
5
+
6
+ def recent_version?(version, minimum)
7
+ version = version.split('.').map { |s| s.to_i }
8
+ minimum = minimum.split('.').map { |s| s.to_i }
9
+ (version <=> minimum) >= 0
10
+ end
11
+
12
+ def windows?
13
+ File::ALT_SEPARATOR == "\\"
14
+ end
15
+
16
+ def mac?
17
+ RUBY_PLATFORM =~ /darwin/i
18
+ end
19
+
20
+ def linux?
21
+ RUBY_PLATFORM =~ /linux/i
22
+ end
23
+
24
+ def unix?
25
+ not windows?
26
+ end
27
+
28
+ def os
29
+ os_name ? "#{os_name} #{os_version}".strip : os_type
30
+ end
31
+
32
+ def full_os
33
+ os_name == os_type ? os : "#{os} like #{os_type}"
34
+ end
35
+
36
+ def os_version
37
+ @os_version ||= has?(:sw_vers) && `sw_vers -productVersion`.chomp
38
+ @os_version ||= has?(:lsb_release) && `lsb_release -r -s`.chomp
39
+ end
40
+
41
+ def os_name
42
+ @os_name ||= has?(:sw_vers) && `sw_vers -productName`.chomp
43
+ @os_name ||= has?(:lsb_release) && `lsb_release -i -s`.chomp
44
+ end
45
+
46
+ def os_type
47
+ @os_type ||= windows? ? 'Windows' : `uname`.chomp
48
+ end
49
+
50
+ def ruby_engine
51
+ defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
52
+ end
53
+
54
+ def ruby_version
55
+ "%s-p%s" % [RUBY_VERSION, RUBY_PATCHLEVEL]
56
+ end
57
+
58
+ def ruby
59
+ case ruby_engine
60
+ when 'ruby' then "Ruby #{ruby_version}"
61
+ when 'jruby' then "JRuby #{JRUBY_VERSION} like Ruby #{ruby_version}"
62
+ when 'rbx' then "Rubinius #{Rubinius.version[/\d\S+/]} like Ruby #{ruby_version}"
63
+ else "#{ruby_engine} like Ruby #{ruby_version}"
64
+ end
65
+ end
66
+
67
+ def rubygems
68
+ return "no RubyGems" unless defined? Gem
69
+ "RubyGems #{Gem::VERSION}"
70
+ end
71
+
72
+ def description(*args)
73
+ [ full_os, ruby, rubygems, *args.flatten].compact.uniq.join("; ")
74
+ end
75
+
76
+ def has?(command)
77
+ return false unless unix?
78
+ @has ||= {}
79
+ @has.fetch(command) { @has[command] = system "which #{command} 2>/dev/null >/dev/null" }
80
+ end
81
+
82
+ def running?(app)
83
+ return false unless unix?
84
+ system "pgrep -u $(whoami) #{app} >/dev/null"
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,3 @@
1
+ module Travis
2
+ VERSION = '1.8.2'
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::Cancel do
4
+ example 'travis cancel' do
5
+ run_cli('cancel', '-t', 'token').should be_success
6
+ $params['id'].should be == "4125095"
7
+ $params['entity'].should be == "builds"
8
+ end
9
+
10
+ example 'travis cancel 6180.1' do
11
+ run_cli('cancel', '6180.1', '-t', 'token').should be_success
12
+ $params['id'].should be == "4125096"
13
+ $params['entity'].should be == "jobs"
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::Encrypt do
4
+ example "travis encrypt foo" do
5
+ run_cli('encrypt', 'foo').should be_success
6
+ stdout.should match(/^".{60,}"\n$/)
7
+ end
8
+
9
+ example "travis encrypt foo -r rails/rails" do
10
+ run_cli('encrypt', 'foo', '-r', 'rails/rails').should be_success
11
+ stdout.should match(/^".{60,}"\n$/)
12
+ end
13
+
14
+ example "travis encrypt foo -i" do
15
+ run_cli('encrypt', 'foo', '-i', '--skip-completion-check', '-r', 'travis-ci/travis.rb').should be_success
16
+ stdout.should start_with("Please add the following to your .travis.yml file:\n\n secure: ")
17
+ end
18
+
19
+ example "cat foo | travis encrypt" do
20
+ run_cli('encrypt') { |i| i.puts('foo') }
21
+ stdout.should match(/\A".{60,}"\n\Z/)
22
+ end
23
+
24
+ example "cat foo\\nbar | travis encrypt -s" do
25
+ run_cli('encrypt', '-s') { |i| i.puts("foo\nbar") }
26
+ stdout.should match(/\A(".{60,}"\n){2}\Z/)
27
+ end
28
+
29
+ example "cat foo\\nbar | travis encrypt" do
30
+ run_cli('encrypt') { |i| i.puts("foo\nbar") }
31
+ stdout.should match(/\A".{60,}"\n\Z/)
32
+ end
33
+
34
+ example "travis encrypt rails/rails foo" do
35
+ run_cli('encrypt', 'rails/rails', 'foo').should be_success
36
+ stderr.should match(/WARNING/)
37
+ end
38
+
39
+ example "travis encrypt foo=foo/bar" do
40
+ run_cli("encrypt", "foo=foo/bar").should be_success
41
+ stderr.should_not match(/WARNING/)
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::Endpoint do
4
+ example "travis endpoint" do
5
+ run_cli('endpoint').should be_success
6
+ stdout.should be == "https://api.travis-ci.org/\n"
7
+ end
8
+
9
+ example "travis endpoint --pro" do
10
+ run_cli('endpoint', '--pro').should be_success
11
+ stdout.should be == "https://api.travis-ci.com/\n"
12
+ end
13
+
14
+ example "travis endpoint -e http://localhost:3000/" do
15
+ run_cli('endpoint', '-e', 'http://localhost:3000/').should be_success
16
+ stdout.should be == "http://localhost:3000/\n"
17
+ end
18
+
19
+ example "TRAVIS_ENDPOINT=http://localhost:3000/ travis endpoint" do
20
+ ENV['TRAVIS_ENDPOINT'] = "http://localhost:3000/"
21
+ run_cli('endpoint').should be_success
22
+ stdout.should be == "http://localhost:3000/\n"
23
+ end
24
+
25
+ example "travis endpoint --github" do
26
+ run_cli('endpoint', '--github').should be_success
27
+ stdout.should be == "https://api.github.com\n"
28
+ end
29
+
30
+ example "travis endpoint -i" do
31
+ run_cli('endpoint', '-i').should be_success
32
+ stdout.should be == "API endpoint: https://api.travis-ci.org/\n"
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::Help do
4
+ example "travis help" do
5
+ run_cli('help').should be_success
6
+ stdout.should include("Usage: travis COMMAND")
7
+ end
8
+
9
+ example "travis --help" do
10
+ run_cli('--help').should be_success
11
+ stdout.should include("Usage: travis COMMAND")
12
+ end
13
+
14
+ example "travis -h" do
15
+ run_cli('-h').should be_success
16
+ stdout.should include("Usage: travis COMMAND")
17
+ end
18
+
19
+ example "travis -?" do
20
+ run_cli('-?').should be_success
21
+ stdout.should include("Usage: travis COMMAND")
22
+ end
23
+
24
+ example "travis help endpoint" do
25
+ run_cli('help', 'endpoint').should be_success
26
+ stdout.should include("Usage: travis endpoint [OPTIONS]")
27
+ end
28
+
29
+ example "travis endpoint --help" do
30
+ run_cli('endpoint', '--help').should be_success
31
+ stdout.should include("Usage: travis endpoint [OPTIONS]")
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::History do
4
+ example 'travis history' do
5
+ run_cli('history').should be_success
6
+ stdout.should be == "#6180 failed: master Associaton -> Association\n"
7
+ end
8
+
9
+ example 'travis history -d' do
10
+ run_cli('history', '-d').should be_success
11
+ stdout.should be =~ /2013-01-13 \d+:55:17 #6180 failed: master Associaton -> Association/
12
+ end
13
+
14
+ example 'travis history -a 6180' do
15
+ run_cli('history', '-a', '6180').should be_success
16
+ stdout.should be == ''
17
+ end
18
+
19
+ example 'travis history -b master' do
20
+ run_cli('history', '-b', 'master').should be_success
21
+ stdout.should be == "#6180 failed: master Associaton -> Association\n"
22
+ end
23
+
24
+ example 'travis history -b not-master' do
25
+ run_cli('history', '-b', 'not-master').should be_success
26
+ stdout.should be_empty
27
+ end
28
+
29
+ example 'travis history -p 5' do
30
+ run_cli('history', '-p', '5').should be_success
31
+ stdout.should be_empty
32
+ end
33
+
34
+ example 'travis history -c' do
35
+ run_cli('history', '-c').should be_success
36
+ stdout.should be == "#6180 failed: master Steve Klabnik Associaton -> Association\n"
37
+ end
38
+ end
@@ -0,0 +1,226 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::CLI::Init do
4
+ old_path = Dir.pwd
5
+ tmp_path = File.expand_path('travis-spec-init', Dir.tmpdir)
6
+
7
+ before(:each) do
8
+ FileUtils.mkdir_p(tmp_path)
9
+ Dir.chdir(tmp_path)
10
+ FileUtils.rm('.travis.yml') if File.exist?('.travis.yml')
11
+ end
12
+
13
+ after(:each) do
14
+ Dir.chdir(old_path)
15
+ end
16
+
17
+ example "travis init fakelanguage" do
18
+ run_cli('init', 'fakelanguage', '--skip-enable', '-r', 'travis-ci/travis.rb').should_not be_success
19
+ stderr.should be == "unknown language fakelanguage\n"
20
+ end
21
+
22
+ shared_examples_for 'travis init' do |language|
23
+ example "travis init #{language} (empty directory)" do
24
+ File.exist?('.travis.yml').should be_false
25
+ run_cli('init', language, '--skip-enable', '-r', 'travis-ci/travis.rb').should be_success
26
+ stdout.should be == ".travis.yml file created!\n"
27
+ File.exist?('.travis.yml').should be_true
28
+ File.read('.travis.yml').should include("language: #{language}")
29
+ end
30
+
31
+ example "travis init #{language} (.travis.yml already exists, using --force)" do
32
+ File.open(".travis.yml", "w") { |f| f << "old file" }
33
+ run_cli('init', language, '--force', '--skip-enable', '-r', 'travis-ci/travis.rb').should be_success
34
+ stdout.should be == ".travis.yml file created!\n"
35
+ File.read(".travis.yml").should_not be == "old file"
36
+ end
37
+
38
+ example "travis init #{language} (.travis.yml already exists, not using --force)" do
39
+ File.open(".travis.yml", "w") { |f| f << "old file" }
40
+ run_cli('init', language, '--skip-enable', '-r', 'travis-ci/travis.rb').should_not be_success
41
+ stderr.should be == ".travis.yml already exists, use --force to override\n"
42
+ File.read('.travis.yml').should be == "old file"
43
+ end
44
+ end
45
+
46
+ describe 'travis init c' do
47
+ it_should_behave_like 'travis init', 'c'
48
+
49
+ let :result do
50
+ run_cli('init', 'c', '--skip-enable', '-r', 'travis-ci/travis.rb')
51
+ YAML.load_file('.travis.yml')
52
+ end
53
+
54
+ it 'sets compiler' do
55
+ result.should include('compiler')
56
+ result['compiler'].should include('clang')
57
+ result['compiler'].should include('gcc')
58
+ end
59
+ end
60
+
61
+ describe 'travis init clojure' do
62
+ it_should_behave_like 'travis init', 'clojure'
63
+ end
64
+
65
+ describe 'travis init cpp' do
66
+ it_should_behave_like 'travis init', 'cpp'
67
+
68
+ let :result do
69
+ run_cli('init', 'cpp', '--skip-enable', '-r', 'travis-ci/travis.rb')
70
+ YAML.load_file('.travis.yml')
71
+ end
72
+
73
+ it 'sets compiler' do
74
+ result.should include('compiler')
75
+ result['compiler'].should include('clang')
76
+ result['compiler'].should include('gcc')
77
+ end
78
+ end
79
+
80
+ describe 'travis init erlang' do
81
+ it_should_behave_like 'travis init', 'erlang'
82
+
83
+ let :result do
84
+ run_cli('init', 'erlang', '--skip-enable', '-r', 'travis-ci/travis.rb')
85
+ YAML.load_file('.travis.yml')
86
+ end
87
+
88
+ it 'sets compiler' do
89
+ result.should include('otp_release')
90
+ result['otp_release'].should include('R16B')
91
+ end
92
+ end
93
+
94
+ describe 'travis init go' do
95
+ it_should_behave_like 'travis init', 'go'
96
+
97
+ let :result do
98
+ run_cli('init', 'go', '--skip-enable', '-r', 'travis-ci/travis.rb')
99
+ YAML.load_file('.travis.yml')
100
+ end
101
+
102
+ it 'sets compiler' do
103
+ result.should include('go')
104
+ result['go'].should include('1.0')
105
+ result['go'].should include('1.3')
106
+ end
107
+ end
108
+
109
+ describe 'travis init groovy' do
110
+ it_should_behave_like 'travis init', 'groovy'
111
+ end
112
+
113
+ describe 'travis init haskell' do
114
+ it_should_behave_like 'travis init', 'haskell'
115
+ end
116
+
117
+ describe 'travis init java' do
118
+ it_should_behave_like 'travis init', 'java'
119
+
120
+ let :result do
121
+ run_cli('init', 'java', '--skip-enable', '-r', 'travis-ci/travis.rb')
122
+ YAML.load_file('.travis.yml')
123
+ end
124
+
125
+ it 'sets compiler' do
126
+ result.should include('jdk')
127
+ result['jdk'].should include('oraclejdk7')
128
+ result['jdk'].should include('openjdk6')
129
+ end
130
+ end
131
+
132
+ describe 'travis init node_js' do
133
+ it_should_behave_like 'travis init', 'node_js'
134
+
135
+ let :result do
136
+ run_cli('init', 'node_js', '--skip-enable', '-r', 'travis-ci/travis.rb')
137
+ YAML.load_file('.travis.yml')
138
+ end
139
+
140
+ it 'sets compiler' do
141
+ result.should include('node_js')
142
+ result['node_js'].should include('0.11')
143
+ result['node_js'].should include('0.10')
144
+ end
145
+ end
146
+
147
+ describe 'travis init objective-c' do
148
+ it_should_behave_like 'travis init', 'objective-c'
149
+ end
150
+
151
+ describe 'travis init perl' do
152
+ it_should_behave_like 'travis init', 'perl'
153
+
154
+ let :result do
155
+ run_cli('init', 'perl', '--skip-enable', '-r', 'travis-ci/travis.rb')
156
+ YAML.load_file('.travis.yml')
157
+ end
158
+
159
+ it 'sets compiler' do
160
+ result.should include('perl')
161
+ result['perl'].should include('5.16')
162
+ result['perl'].should include('5.14')
163
+ end
164
+ end
165
+
166
+ describe 'travis init php' do
167
+ it_should_behave_like 'travis init', 'php'
168
+
169
+ let :result do
170
+ run_cli('init', 'php', '--skip-enable', '-r', 'travis-ci/travis.rb')
171
+ YAML.load_file('.travis.yml')
172
+ end
173
+
174
+ it 'sets compiler' do
175
+ result.should include('php')
176
+ result['php'].should include('5.5')
177
+ result['php'].should include('5.4')
178
+ end
179
+ end
180
+
181
+ describe 'travis init python' do
182
+ it_should_behave_like 'travis init', 'python'
183
+
184
+ let :result do
185
+ run_cli('init', 'python', '--skip-enable', '-r', 'travis-ci/travis.rb')
186
+ YAML.load_file('.travis.yml')
187
+ end
188
+
189
+ it 'sets compiler' do
190
+ result.should include('python')
191
+ result['python'].should include('2.7')
192
+ result['python'].should include('3.3')
193
+ end
194
+ end
195
+
196
+ describe 'travis init ruby' do
197
+ it_should_behave_like 'travis init', 'ruby'
198
+
199
+ let :result do
200
+ run_cli('init', 'ruby', '--skip-enable', '-r', 'travis-ci/travis.rb')
201
+ YAML.load_file('.travis.yml')
202
+ end
203
+
204
+ it 'sets compiler' do
205
+ result.should include('rvm')
206
+ result['rvm'].should include('1.9.3')
207
+ result['rvm'].should include('2.0.0')
208
+ result['rvm'].should_not include('1.8.7')
209
+ end
210
+ end
211
+
212
+ describe 'travis init scala' do
213
+ it_should_behave_like 'travis init', 'scala'
214
+
215
+ let :result do
216
+ run_cli('init', 'scala', '--skip-enable', '-r', 'travis-ci/travis.rb')
217
+ YAML.load_file('.travis.yml')
218
+ end
219
+
220
+ it 'sets compiler' do
221
+ result.should include('scala')
222
+ result['scala'].should include('2.10.1')
223
+ result['scala'].should include('2.9.3')
224
+ end
225
+ end
226
+ end