travis 1.11.0 → 1.12.0

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 (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -4
  3. data/Rakefile +22 -20
  4. data/bin/travis +5 -3
  5. data/examples/org_overview.rb +2 -0
  6. data/examples/pro_auth.rb +3 -1
  7. data/examples/stream.rb +5 -3
  8. data/lib/travis/auto_login.rb +2 -0
  9. data/lib/travis/cli/accounts.rb +12 -9
  10. data/lib/travis/cli/api_command.rb +85 -81
  11. data/lib/travis/cli/branches.rb +8 -6
  12. data/lib/travis/cli/cache.rb +48 -44
  13. data/lib/travis/cli/cancel.rb +4 -2
  14. data/lib/travis/cli/command.rb +170 -142
  15. data/lib/travis/cli/console.rb +5 -5
  16. data/lib/travis/cli/disable.rb +4 -2
  17. data/lib/travis/cli/enable.rb +14 -12
  18. data/lib/travis/cli/encrypt.rb +57 -57
  19. data/lib/travis/cli/encrypt_file.rb +29 -18
  20. data/lib/travis/cli/endpoint.rb +9 -7
  21. data/lib/travis/cli/env.rb +13 -8
  22. data/lib/travis/cli/help.rb +10 -8
  23. data/lib/travis/cli/history.rb +19 -15
  24. data/lib/travis/cli/init.rb +27 -24
  25. data/lib/travis/cli/lint.rb +10 -8
  26. data/lib/travis/cli/login.rb +17 -11
  27. data/lib/travis/cli/logout.rb +4 -2
  28. data/lib/travis/cli/logs.rb +28 -19
  29. data/lib/travis/cli/monitor.rb +11 -8
  30. data/lib/travis/cli/open.rb +17 -14
  31. data/lib/travis/cli/parser.rb +2 -0
  32. data/lib/travis/cli/pubkey.rb +13 -11
  33. data/lib/travis/cli/raw.rb +4 -3
  34. data/lib/travis/cli/repo_command.rb +123 -112
  35. data/lib/travis/cli/report.rb +40 -33
  36. data/lib/travis/cli/repos.rb +14 -9
  37. data/lib/travis/cli/requests.rb +13 -12
  38. data/lib/travis/cli/restart.rb +4 -2
  39. data/lib/travis/cli/settings.rb +41 -35
  40. data/lib/travis/cli/setup/anynines.rb +7 -6
  41. data/lib/travis/cli/setup/appfog.rb +6 -4
  42. data/lib/travis/cli/setup/artifacts.rb +7 -5
  43. data/lib/travis/cli/setup/biicode.rb +6 -4
  44. data/lib/travis/cli/setup/cloud_66.rb +6 -4
  45. data/lib/travis/cli/setup/cloud_control.rb +8 -6
  46. data/lib/travis/cli/setup/cloud_files.rb +7 -5
  47. data/lib/travis/cli/setup/cloud_foundry.rb +9 -7
  48. data/lib/travis/cli/setup/code_deploy.rb +33 -29
  49. data/lib/travis/cli/setup/deis.rb +8 -6
  50. data/lib/travis/cli/setup/divshot.rb +20 -18
  51. data/lib/travis/cli/setup/elastic_beanstalk.rb +10 -8
  52. data/lib/travis/cli/setup/engine_yard.rb +9 -7
  53. data/lib/travis/cli/setup/gcs.rb +9 -7
  54. data/lib/travis/cli/setup/hackage.rb +6 -4
  55. data/lib/travis/cli/setup/heroku.rb +10 -4
  56. data/lib/travis/cli/setup/modulus.rb +5 -3
  57. data/lib/travis/cli/setup/ninefold.rb +7 -5
  58. data/lib/travis/cli/setup/nodejitsu.rb +6 -4
  59. data/lib/travis/cli/setup/npm.rb +6 -4
  60. data/lib/travis/cli/setup/open_shift.rb +8 -6
  61. data/lib/travis/cli/setup/opsworks.rb +24 -22
  62. data/lib/travis/cli/setup/pypi.rb +7 -5
  63. data/lib/travis/cli/setup/releases.rb +6 -6
  64. data/lib/travis/cli/setup/ruby_gems.rb +7 -5
  65. data/lib/travis/cli/setup/s3.rb +12 -8
  66. data/lib/travis/cli/setup/sauce_connect.rb +7 -5
  67. data/lib/travis/cli/setup/service.rb +36 -25
  68. data/lib/travis/cli/setup.rb +7 -3
  69. data/lib/travis/cli/show.rb +10 -8
  70. data/lib/travis/cli/sshkey.rb +31 -28
  71. data/lib/travis/cli/status.rb +5 -3
  72. data/lib/travis/cli/sync.rb +9 -7
  73. data/lib/travis/cli/token.rb +4 -2
  74. data/lib/travis/cli/version.rb +4 -3
  75. data/lib/travis/cli/whatsup.rb +10 -8
  76. data/lib/travis/cli/whoami.rb +2 -2
  77. data/lib/travis/cli.rb +39 -36
  78. data/lib/travis/client/account.rb +8 -6
  79. data/lib/travis/client/artifact.rb +16 -12
  80. data/lib/travis/client/auto_login.rb +7 -4
  81. data/lib/travis/client/broadcast.rb +2 -0
  82. data/lib/travis/client/build.rb +7 -3
  83. data/lib/travis/client/cache.rb +4 -2
  84. data/lib/travis/client/commit.rb +5 -2
  85. data/lib/travis/client/entity.rb +50 -46
  86. data/lib/travis/client/env_var.rb +13 -8
  87. data/lib/travis/client/error.rb +5 -3
  88. data/lib/travis/client/has_uuid.rb +3 -1
  89. data/lib/travis/client/job.rb +8 -3
  90. data/lib/travis/client/lint_result.rb +2 -0
  91. data/lib/travis/client/listener.rb +70 -55
  92. data/lib/travis/client/methods.rb +10 -5
  93. data/lib/travis/client/namespace.rb +20 -16
  94. data/lib/travis/client/not_loadable.rb +3 -1
  95. data/lib/travis/client/repository.rb +34 -22
  96. data/lib/travis/client/request.rb +5 -2
  97. data/lib/travis/client/restartable.rb +2 -0
  98. data/lib/travis/client/session.rb +118 -88
  99. data/lib/travis/client/settings.rb +8 -3
  100. data/lib/travis/client/singleton_setting.rb +2 -0
  101. data/lib/travis/client/ssh_key.rb +2 -0
  102. data/lib/travis/client/states.rb +8 -6
  103. data/lib/travis/client/user.rb +2 -0
  104. data/lib/travis/client/weak_entity.rb +6 -3
  105. data/lib/travis/client.rb +4 -1
  106. data/lib/travis/pro/auto_login.rb +2 -0
  107. data/lib/travis/pro.rb +2 -0
  108. data/lib/travis/tools/assets.rb +6 -3
  109. data/lib/travis/tools/completion.rb +10 -6
  110. data/lib/travis/tools/formatter.rb +20 -14
  111. data/lib/travis/tools/github.rb +59 -49
  112. data/lib/travis/tools/notification.rb +18 -13
  113. data/lib/travis/tools/safe_string.rb +4 -1
  114. data/lib/travis/tools/ssl_key.rb +5 -2
  115. data/lib/travis/tools/system.rb +11 -6
  116. data/lib/travis/version.rb +3 -1
  117. data/lib/travis.rb +3 -1
  118. data/spec/cli/api_command_spec.rb +11 -8
  119. data/spec/cli/cancel_spec.rb +2 -4
  120. data/spec/cli/encrypt_file_spec.rb +9 -7
  121. data/spec/cli/encrypt_spec.rb +19 -17
  122. data/spec/cli/endpoint_spec.rb +12 -10
  123. data/spec/cli/help_spec.rb +14 -12
  124. data/spec/cli/history_spec.rb +2 -0
  125. data/spec/cli/init_spec.rb +35 -33
  126. data/spec/cli/logs_spec.rb +2 -0
  127. data/spec/cli/open_spec.rb +6 -4
  128. data/spec/cli/repo_command_spec.rb +8 -4
  129. data/spec/cli/restart_spec.rb +2 -4
  130. data/spec/cli/setup/service_spec.rb +17 -18
  131. data/spec/cli/setup_spec.rb +2 -4
  132. data/spec/cli/show_spec.rb +4 -2
  133. data/spec/cli/status_spec.rb +7 -5
  134. data/spec/cli/token_spec.rb +7 -5
  135. data/spec/cli/version_spec.rb +2 -0
  136. data/spec/cli/whoami_spec.rb +9 -7
  137. data/spec/client/account_spec.rb +28 -20
  138. data/spec/client/auto_login_spec.rb +12 -9
  139. data/spec/client/broadcast_spec.rb +5 -3
  140. data/spec/client/build_spec.rb +28 -24
  141. data/spec/client/commit_spec.rb +17 -14
  142. data/spec/client/job_spec.rb +27 -23
  143. data/spec/client/methods_spec.rb +8 -4
  144. data/spec/client/namespace_spec.rb +8 -4
  145. data/spec/client/repository_spec.rb +33 -30
  146. data/spec/client/session_spec.rb +71 -67
  147. data/spec/client/user_spec.rb +13 -10
  148. data/spec/client_spec.rb +6 -4
  149. data/spec/pro_spec.rb +5 -3
  150. data/spec/spec_helper.rb +3 -1
  151. data/spec/support/fake_api.rb +662 -662
  152. data/spec/support/fake_github.rb +6 -3
  153. data/spec/support/helpers.rb +13 -8
  154. data/spec/travis_spec.rb +5 -3
  155. data/travis.gemspec +400 -399
  156. metadata +30 -50
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
1
4
  require 'travis/tools/system'
2
5
  require 'yaml'
3
6
  require 'json'
@@ -11,21 +14,21 @@ module Travis
11
14
  GITHUB_HOST = 'github.com'
12
15
 
13
16
  attr_accessor :api_url, :scopes, :github_token, :drop_token, :callback, :explode, :after_tokens,
14
- :login_header, :auto_token, :note,
15
- :hub_path, :oauth_paths, :composer_path, :git_config_keys, :debug, :no_token, :check_token
17
+ :login_header, :auto_token, :note,
18
+ :hub_path, :oauth_paths, :composer_path, :git_config_keys, :debug, :no_token, :check_token
16
19
 
17
20
  def initialize(options = nil)
18
21
  @check_token = true
19
- @ask_login = proc { raise "ask_login callback not set" }
20
- @after_tokens = proc { }
22
+ @ask_login = proc { raise 'ask_login callback not set' }
23
+ @after_tokens = proc {}
21
24
  @debug = proc { |_| }
22
25
  @hub_path = ENV['HUB_CONFIG'] || '~/.config/hub'
23
26
  @oauth_paths = ['~/.github-oauth-token']
24
- @composer_path = "~/.composer/config.json"
27
+ @composer_path = '~/.composer/config.json'
25
28
  @note = 'temporary token'
26
29
  @git_config_keys = %w[github.token github.oauth-token]
27
30
  @scopes = ['user', 'user:email', 'repo'] # overridden by value from /config
28
- options.each_pair { |k,v| send("#{k}=", v) if respond_to? "#{k}=" } if options
31
+ options&.each_pair { |k, v| send("#{k}=", v) if respond_to? "#{k}=" }
29
32
  yield self if block_given?
30
33
  end
31
34
 
@@ -37,12 +40,13 @@ module Travis
37
40
  require 'gh' unless defined? GH
38
41
  possible_tokens { |t| yield(t) if acceptable?(t) }
39
42
  ensure
40
- callback, self.callback = self.callback, nil
41
- callback.call if callback
43
+ callback = self.callback
44
+ self.callback = nil
45
+ callback&.call
42
46
  end
43
47
 
44
- def with_session(&block)
45
- with_token { |t| GH.with(:token => t) { yield(t) } }
48
+ def with_session
49
+ with_token { |t| GH.with(token: t) { yield(t) } }
46
50
  end
47
51
 
48
52
  def possible_tokens(&block)
@@ -66,6 +70,7 @@ module Travis
66
70
 
67
71
  def git_tokens
68
72
  return unless System.has? 'git'
73
+
69
74
  git_config_keys.each do |key|
70
75
  `git config --get-all #{key}`.each_line do |line|
71
76
  token = line.strip
@@ -83,11 +88,11 @@ module Travis
83
88
 
84
89
  def hub_tokens
85
90
  hub.fetch(host, []).each do |entry|
86
- yield entry["oauth_token"] if entry["oauth_token"]
91
+ yield entry['oauth_token'] if entry['oauth_token']
87
92
  end
88
93
  end
89
94
 
90
- def oauth_file_tokens(&block)
95
+ def oauth_file_tokens
91
96
  oauth_paths.each do |path|
92
97
  file(path) do |content|
93
98
  token = content.strip
@@ -103,12 +108,12 @@ module Travis
103
108
  end
104
109
 
105
110
  def issuepost_token(&block)
106
- security(:generic, :w, "-l issuepost.github.access_token", "issuepost token", &block) if host == 'github.com'
111
+ security(:generic, :w, '-l issuepost.github.access_token', 'issuepost token', &block) if host == 'github.com'
107
112
  end
108
113
 
109
114
  def github_for_mac_token(&block)
110
115
  command = '-s "github.com/mac"'
111
- security(:internet, :w, command, "GitHub for Mac token", &block) if host == 'github.com'
116
+ security(:internet, :w, command, 'GitHub for Mac token', &block) if host == 'github.com'
112
117
  end
113
118
 
114
119
  def host
@@ -117,57 +122,62 @@ module Travis
117
122
 
118
123
  def api_host
119
124
  return GITHUB_API unless api_url
125
+
120
126
  api_url[%r{^(?:https?://)?([^/]+)}, 1]
121
127
  end
122
128
 
123
129
  def acceptable?(token)
124
130
  return true unless check_token
125
- gh = GH.with(:token => token)
126
- user = gh['user']
131
+
132
+ gh = GH.with(token:)
133
+ gh['user']
127
134
 
128
135
  true
129
- rescue GH::Error => error
130
- debug "token is not acceptable: #{gh_error(error)}"
136
+ rescue GH::Error => e
137
+ debug "token is not acceptable: #{gh_error(e)}"
131
138
  false
132
139
  end
133
140
 
134
141
  private
135
142
 
136
- def gh_error(error)
137
- raise error if explode
138
- if error.info.key? :response_body
139
- JSON.parse(error.info[:response_body])["message"].to_s
140
- else
141
- "Unknown error"
142
- end
143
- end
143
+ def gh_error(error)
144
+ raise error if explode
144
145
 
145
- def debug(line)
146
- return unless @debug
147
- @debug.call "Tools::Github: #{line}"
146
+ if error.info.key? :response_body
147
+ JSON.parse(error.info[:response_body])['message'].to_s
148
+ else
149
+ 'Unknown error'
148
150
  end
151
+ end
149
152
 
150
- def security(type, key, arg, name)
151
- return false unless System.has? 'security'
152
- return false unless system "security find-#{type}-password #{arg} 2>/dev/null >/dev/null"
153
- debug "requesting to load #{name} from keychain"
154
- result = %x[security find-#{type}-password #{arg} -#{key} 2>&1].chomp
155
- $?.success? ? yield(result) : debug("request denied")
156
- rescue => e
157
- raise e if explode
158
- end
153
+ def debug(line)
154
+ return unless @debug
159
155
 
160
- def file(path, default = nil)
161
- path &&= File.expand_path(path)
162
- @file ||= {}
163
- @file[path] ||= if path and File.readable?(path)
164
- debug "reading #{path}"
165
- yield File.read(path)
166
- end
167
- @file[path] || default
168
- rescue => e
169
- raise e if explode
170
- end
156
+ @debug.call "Tools::Github: #{line}"
157
+ end
158
+
159
+ def security(type, key, arg, name)
160
+ return false unless System.has? 'security'
161
+ return false unless system "security find-#{type}-password #{arg} 2>/dev/null >/dev/null"
162
+
163
+ debug "requesting to load #{name} from keychain"
164
+ result = `security find-#{type}-password #{arg} -#{key} 2>&1`.chomp
165
+ $CHILD_STATUS.success? ? yield(result) : debug('request denied')
166
+ rescue StandardError => e
167
+ raise e if explode
168
+ end
169
+
170
+ def file(path, default = nil)
171
+ path &&= File.expand_path(path)
172
+ @file ||= {}
173
+ @file[path] ||= if path && File.readable?(path)
174
+ debug "reading #{path}"
175
+ yield File.read(path)
176
+ end
177
+ @file[path] || default
178
+ rescue StandardError => e
179
+ raise e if explode
180
+ end
171
181
  end
172
182
  end
173
183
  end
@@ -1,31 +1,35 @@
1
- require "travis"
2
- require "travis/tools/system"
3
- require "travis/tools/assets"
4
- require "cgi"
1
+ # frozen_string_literal: true
2
+
3
+ require 'travis'
4
+ require 'travis/tools/system'
5
+ require 'travis/tools/assets'
6
+ require 'cgi'
5
7
 
6
8
  module Travis
7
9
  module Tools
8
10
  module Notification
9
- extend self
10
- DEFAULT = [:osx, :growl, :libnotify]
11
+ module_function
12
+
13
+ DEFAULT = %i[osx growl libnotify].freeze
11
14
  ICON = Assets['notifications/icon.png']
12
15
 
13
16
  def new(*list)
14
17
  list.concat(DEFAULT) if list.empty?
15
18
  notification = list.map { |n| get(n) }.detect { |n| n.available? }
16
- raise ArgumentError, "no notification system found (looked for #{list.join(", ")})" unless notification
19
+ raise ArgumentError, "no notification system found (looked for #{list.join(', ')})" unless notification
20
+
17
21
  notification
18
22
  end
19
23
 
20
24
  def get(name)
21
25
  const = constants.detect { |c| c.to_s[/[^:]+$/].downcase == name.to_s }
22
- raise ArgumentError, "unknown notifications type %p" % name unless const
26
+ raise ArgumentError, 'unknown notifications type %p' % name unless const
27
+
23
28
  const_get(const).new
24
29
  end
25
30
 
26
31
  class Dummy
27
- def notify(title, body)
28
- end
32
+ def notify(title, body); end
29
33
 
30
34
  def available?
31
35
  true
@@ -33,14 +37,15 @@ module Travis
33
37
  end
34
38
 
35
39
  class OSX
36
- BIN_PATH = Assets["notifications/Travis CI.app/Contents/MacOS/Travis CI"]
40
+ BIN_PATH = Assets['notifications/Travis CI.app/Contents/MacOS/Travis CI']
37
41
 
38
42
  def notify(title, body)
39
43
  system BIN_PATH, '-message', body.to_s, '-title', title.to_s, '-sender', 'org.travis-ci.Travis-CI'
40
44
  end
41
45
 
42
46
  def available?
43
- System.mac? and System.recent_version?(System.os_version.to_s, '10.8') and System.running? "NotificationCenter"
47
+ System.mac? and System.recent_version?(System.os_version.to_s,
48
+ '10.8') and System.running? 'NotificationCenter'
44
49
  end
45
50
  end
46
51
 
@@ -50,7 +55,7 @@ module Travis
50
55
  end
51
56
 
52
57
  def available?
53
- System.has? 'growlnotify' and System.running? "Growl"
58
+ System.has? 'growlnotify' and System.running? 'Growl'
54
59
  end
55
60
  end
56
61
 
@@ -1,10 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Travis
2
4
  module Tools
3
5
  module SafeString
4
- extend self
6
+ module_function
5
7
 
6
8
  def encoded(string)
7
9
  return string unless string.respond_to? :encode
10
+
8
11
  string.encode 'utf-8'
9
12
  rescue Encoding::UndefinedConversionError
10
13
  string.force_encoding 'utf-8'
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
2
4
  require 'base64'
3
5
 
4
6
  module Travis
5
7
  module Tools
6
8
  module SSLKey
7
- extend self
9
+ module_function
8
10
 
9
11
  def generate_rsa(size = 2048)
10
12
  OpenSSL::PKey::RSA.generate(size)
@@ -40,7 +42,8 @@ module Travis
40
42
  end
41
43
 
42
44
  def to_byte_array(num, *significant)
43
- return significant if num.between?(-1, 0) and significant[0][7] == num[7]
45
+ return significant if num.between?(-1, 0) && (significant[0][7] == num[7])
46
+
44
47
  to_byte_array(*num.divmod(256)) + significant
45
48
  end
46
49
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Travis
2
4
  module Tools
3
5
  module System
4
- extend self
6
+ module_function
5
7
 
6
8
  def recent_version?(version, minimum)
7
9
  version = version.split('.').map { |s| s.to_i }
@@ -10,7 +12,7 @@ module Travis
10
12
  end
11
13
 
12
14
  def windows?
13
- File::ALT_SEPARATOR == "\\"
15
+ File::ALT_SEPARATOR == '\\'
14
16
  end
15
17
 
16
18
  def mac?
@@ -22,7 +24,7 @@ module Travis
22
24
  end
23
25
 
24
26
  def unix?
25
- not windows?
27
+ !windows?
26
28
  end
27
29
 
28
30
  def os
@@ -52,7 +54,7 @@ module Travis
52
54
  end
53
55
 
54
56
  def ruby_version
55
- "%s-p%s" % [RUBY_VERSION, RUBY_PATCHLEVEL]
57
+ format('%s-p%s', RUBY_VERSION, RUBY_PATCHLEVEL)
56
58
  end
57
59
 
58
60
  def ruby
@@ -65,22 +67,25 @@ module Travis
65
67
  end
66
68
 
67
69
  def rubygems
68
- return "no RubyGems" unless defined? Gem
70
+ return 'no RubyGems' unless defined? Gem
71
+
69
72
  "RubyGems #{Gem::VERSION}"
70
73
  end
71
74
 
72
75
  def description(*args)
73
- [ full_os, ruby, rubygems, *args.flatten].compact.uniq.join("; ")
76
+ [full_os, ruby, rubygems, *args.flatten].compact.uniq.join('; ')
74
77
  end
75
78
 
76
79
  def has?(command)
77
80
  return false unless unix?
81
+
78
82
  @has ||= {}
79
83
  @has.fetch(command) { @has[command] = system "command -v #{command} 2>/dev/null >/dev/null" }
80
84
  end
81
85
 
82
86
  def running?(app)
83
87
  return false unless unix?
88
+
84
89
  system "/usr/bin/pgrep -u $(whoami) #{app} >/dev/null"
85
90
  end
86
91
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Travis
2
- VERSION = '1.11.0'
4
+ VERSION = '1.12.0'
3
5
  end
data/lib/travis.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Travis
2
4
  autoload :Client, 'travis/client'
3
5
  autoload :CLI, 'travis/cli'
4
6
  autoload :Pro, 'travis/pro'
5
7
  autoload :Version, 'travis/version'
6
8
 
7
- include Client::Namespace.new(Client::ORG_URI)
9
+ include Client::Namespace.new(Client::COM_URI)
8
10
  end
@@ -1,16 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Travis::CLI::ApiCommand do
4
6
  describe 'enterprise' do
5
7
  travis_config_path = ENV['TRAVIS_CONFIG_PATH']
8
+ subject(:api_command) { described_class.new }
6
9
 
7
10
  before do
8
11
  ENV['TRAVIS_CONFIG_PATH'] = File.expand_path '../support', File.dirname(__FILE__)
9
- config = subject.send(:load_file, 'fake_travis_config.yml')
10
- subject.config = YAML.load(config)
12
+ config = api_command.send(:load_file, 'fake_travis_config.yml')
13
+ api_command.config = YAML.load(config)
11
14
 
12
- subject.api_endpoint = 'https://travis-ci-enterprise/api'
13
- subject.enterprise_name = 'default'
15
+ api_command.api_endpoint = 'https://travis-ci-enterprise/api'
16
+ api_command.enterprise_name = 'default'
14
17
  end
15
18
 
16
19
  after do
@@ -19,19 +22,19 @@ describe Travis::CLI::ApiCommand do
19
22
 
20
23
  describe '#setup_enterprise' do
21
24
  before do
22
- subject.send(:setup_enterprise)
25
+ api_command.send(:setup_enterprise)
23
26
  end
24
27
 
25
28
  it 'keeps verifying peers' do
26
- subject.insecure.should be_falsey
29
+ api_command.insecure.should be_falsey
27
30
  end
28
31
 
29
32
  it 'uses default CAs' do
30
- subject.session.ssl.should_not include(:ca_file)
33
+ api_command.session.ssl.should_not include(:ca_file)
31
34
  end
32
35
 
33
36
  it 'flags endpoint' do
34
- subject.endpoint_config.should include('enterprise' => true)
37
+ api_command.endpoint_config.should include('enterprise' => true)
35
38
  end
36
39
  end
37
40
  end
@@ -1,15 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Travis::CLI::Cancel do
4
6
  example 'travis cancel' do
5
7
  run_cli('cancel', '-t', 'token').should be_success
6
- $params['id'].should be == "4125095"
7
- $params['entity'].should be == "builds"
8
8
  end
9
9
 
10
10
  example 'travis cancel 6180.1' do
11
11
  run_cli('cancel', '6180.1', '-t', 'token').should be_success
12
- $params['id'].should be == "4125096"
13
- $params['entity'].should be == "jobs"
14
12
  end
15
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'fileutils'
3
5
  require 'digest'
@@ -5,22 +7,22 @@ require 'digest'
5
7
  describe Travis::CLI::EncryptFile do
6
8
  CMD_TARGET = 'README.md'
7
9
 
8
- before :each do
9
- Digest.stub(:hexencode).and_return "randomhex" # to avoid relying on Dir.pwd value for hex
10
+ before do
11
+ Digest.stub(:hexencode).and_return 'randomhex' # to avoid relying on Dir.pwd value for hex
10
12
  end
11
13
 
12
- after :each do
14
+ after do
13
15
  FileUtils.rm_f "#{CMD_TARGET}.enc"
14
16
  end
15
17
 
16
18
  example "travis encrypt-file #{CMD_TARGET}" do
17
19
  run_cli('encrypt-file', CMD_TARGET).should be_success
18
- File.exists?("#{CMD_TARGET}.enc").should be true
20
+ File.exist?("#{CMD_TARGET}.enc").should be true
19
21
  end
20
22
 
21
23
  example "travis encrypt-file #{CMD_TARGET} -a" do
22
- run_cli('encrypt-file', CMD_TARGET, '-a') { |i| i.puts "n" }.should be_success
23
- stdout.should match /Overwrite the config file/
24
- File.exists?("#{CMD_TARGET}.enc").should be true
24
+ run_cli('encrypt-file', CMD_TARGET, '-a') { |i| i.puts 'n' }.should be_success
25
+ stdout.should match(/Overwrite the config file/)
26
+ File.exist?("#{CMD_TARGET}.enc").should be true
25
27
  end
26
28
  end
@@ -1,67 +1,69 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Travis::CLI::Encrypt do
4
- example "travis encrypt foo" do
6
+ example 'travis encrypt foo' do
5
7
  run_cli('encrypt', 'foo').should be_success
6
8
  stdout.should match(/^".{60,}"\n$/)
7
9
  end
8
10
 
9
- example "travis encrypt foo -r rails/rails" do
11
+ example 'travis encrypt foo -r rails/rails' do
10
12
  run_cli('encrypt', 'foo', '-r', 'rails/rails').should be_success
11
13
  stdout.should match(/^".{60,}"\n$/)
12
14
  end
13
15
 
14
- example "travis encrypt foo -i" do
16
+ example 'travis encrypt foo -i' do
15
17
  run_cli('encrypt', 'foo', '-i', '--skip-completion-check', '-r', 'travis-ci/travis.rb').should be_success
16
18
  stdout.should start_with("Please add the following to your .travis.yml file:\n\n secure: ")
17
19
  end
18
20
 
19
- example "cat foo | travis encrypt" do
21
+ example 'cat foo | travis encrypt' do
20
22
  run_cli('encrypt') { |i| i.puts('foo') }
21
23
  stdout.should match(/\A".{60,}"\n\Z/)
22
24
  end
23
25
 
24
- example "cat foo\\nbar | travis encrypt -s" do
26
+ example 'cat foo\\nbar | travis encrypt -s' do
25
27
  run_cli('encrypt', '-s') { |i| i.puts("foo\nbar") }
26
28
  stdout.should match(/\A(".{60,}"\n){2}\Z/)
27
29
  end
28
30
 
29
- example "cat foo\\nbar | travis encrypt" do
31
+ example 'cat foo\\nbar | travis encrypt' do
30
32
  run_cli('encrypt') { |i| i.puts("foo\nbar") }
31
33
  stdout.should match(/\A".{60,}"\n\Z/)
32
34
  end
33
35
 
34
- example "travis encrypt rails/rails foo" do
36
+ example 'travis encrypt rails/rails foo' do
35
37
  run_cli('encrypt', 'rails/rails', 'foo').should be_success
36
38
  stderr.should match(/WARNING/)
37
39
  end
38
40
 
39
- example "travis encrypt foo=foo/bar" do
40
- run_cli("encrypt", "foo=foo/bar").should be_success
41
+ example 'travis encrypt foo=foo/bar' do
42
+ run_cli('encrypt', 'foo=foo/bar').should be_success
41
43
  stderr.should_not match(/WARNING/)
42
44
  end
43
45
 
44
- example "travis encrypt FOO bar -a" do
46
+ example 'travis encrypt FOO bar -a' do
45
47
  described_class.any_instance.stub(:save_travis_config)
46
- run_cli("encrypt", "FOO", "bar", "-a") { |i| i.puts "foo" }.should be_success
48
+ run_cli('encrypt', 'FOO', 'bar', '-a') { |i| i.puts 'foo' }.should be_success
47
49
  stderr.should match(/Environment variables in env\.global should be formatted as FOO=bar/)
48
50
  end
49
51
 
50
- example "travis encrypt FOO bar -a foo" do
52
+ example 'travis encrypt FOO bar -a foo' do
51
53
  described_class.any_instance.stub(:save_travis_config)
52
- run_cli("encrypt", "FOO", "bar", "-a", "foo") { |i| i.puts "foo" }.should be_success
54
+ run_cli('encrypt', 'FOO', 'bar', '-a', 'foo') { |i| i.puts 'foo' }.should be_success
53
55
  stdout.should match(/Overwrite the config file/)
54
56
  end
55
57
 
56
- example "travis encrypt FOO bar -a --no-interactive" do
58
+ example 'travis encrypt FOO bar -a --no-interactive' do
57
59
  described_class.any_instance.stub(:save_travis_config)
58
- run_cli("encrypt", "FOO", "bar", "-a", "--no-interactive").should be_success
60
+ run_cli('encrypt', 'FOO', 'bar', '-a', '--no-interactive').should be_success
59
61
  stderr.should match(/Environment variables in env\.global should be formatted as FOO=bar/)
60
62
  end
61
63
 
62
- example "travis encrypt FOO=bar -a foo --no-interactive" do
64
+ example 'travis encrypt FOO=bar -a foo --no-interactive' do
63
65
  described_class.any_instance.stub(:save_travis_config)
64
- run_cli("encrypt", "FOO=bar", "-a", "foo", "--no-interactive").should be_success
66
+ run_cli('encrypt', 'FOO=bar', '-a', 'foo', '--no-interactive').should be_success
65
67
  stdout.should be_empty
66
68
  end
67
69
  end
@@ -1,39 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Travis::CLI::Endpoint do
4
- example "travis endpoint" do
6
+ example 'travis endpoint' do
5
7
  run_cli('endpoint').should be_success
6
- stdout.should be == "https://api.travis-ci.org/\n"
8
+ stdout.should be == "https://api.travis-ci.com/\n"
7
9
  end
8
10
 
9
- example "travis endpoint --pro" do
11
+ example 'travis endpoint --pro' do
10
12
  run_cli('endpoint', '--pro').should be_success
11
13
  stdout.should be == "https://api.travis-ci.com/\n"
12
14
  end
13
15
 
14
- example "travis endpoint --com" do
16
+ example 'travis endpoint --com' do
15
17
  run_cli('endpoint', '--com').should be_success
16
18
  stdout.should be == "https://api.travis-ci.com/\n"
17
19
  end
18
20
 
19
- example "travis endpoint -e http://localhost:3000/" do
21
+ example 'travis endpoint -e http://localhost:3000/' do
20
22
  run_cli('endpoint', '-e', 'http://localhost:3000/').should be_success
21
23
  stdout.should be == "http://localhost:3000/\n"
22
24
  end
23
25
 
24
- example "TRAVIS_ENDPOINT=http://localhost:3000/ travis endpoint" do
25
- ENV['TRAVIS_ENDPOINT'] = "http://localhost:3000/"
26
+ example 'TRAVIS_ENDPOINT=http://localhost:3000/ travis endpoint' do
27
+ ENV['TRAVIS_ENDPOINT'] = 'http://localhost:3000/'
26
28
  run_cli('endpoint').should be_success
27
29
  stdout.should be == "http://localhost:3000/\n"
28
30
  end
29
31
 
30
- example "travis endpoint --github" do
32
+ example 'travis endpoint --github' do
31
33
  run_cli('endpoint', '--github').should be_success
32
34
  stdout.should be == "https://api.github.com\n"
33
35
  end
34
36
 
35
- example "travis endpoint -i" do
37
+ example 'travis endpoint -i' do
36
38
  run_cli('endpoint', '-i').should be_success
37
- stdout.should be == "API endpoint: https://api.travis-ci.org/\n"
39
+ stdout.should be == "API endpoint: https://api.travis-ci.com/\n"
38
40
  end
39
41
  end