circle-cli 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://circleci.com/api/v1/project/mtchavez/rb-array-sorting/5/tests?circle-token=123
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Origin:
24
+ - "*"
25
+ Content-Encoding:
26
+ - gzip
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Date:
30
+ - Sun, 29 Mar 2015 22:55:57 GMT
31
+ Server:
32
+ - nginx
33
+ Set-Cookie:
34
+ - ab_test_user_seed=0.39268708614490533;Expires=Tue, 29 Mar 2016 22:55:57 +0000;Path=/;Secure
35
+ - ring-session=CzS62UD0EyDOhDL38YweoV%2FYDBdyTa%2BoIWPRBOS9gkFdfeKS0QJGnLEHwYv2CY%2FeolK0Dypk3Y1pFS7zhdg7SDuK3WtWbC5WHu1Aq8zl8WLrAvNfsdhvIpgsMB6TOoI%2BJm3H9j64%2F91oBtMt%2B4jStTAEgX4EBIK%2Bdnym0zrRyRFUPG%2Bc0lLwzZRZ%2BoBbP3xANRHXBQpiMIPpZXVcYOS2SRfdYY9OFTJue5ufEwekGAA%3D--OgruTcmL77%2Fr1UDxot%2B3j13CkEcoc7ts07yAbO6ii3k%3D;Secure;Max-Age=31536000;Expires=Tue,
36
+ 29 Mar 2016 20:42:56 +0000;HttpOnly;Path=/
37
+ X-Circleci-Identity:
38
+ - i-1c5e7a33
39
+ X-Circleci-Scopes:
40
+ - ":all"
41
+ - ":none"
42
+ - ":read-settings"
43
+ - ":status"
44
+ - ":view-builds"
45
+ - ":write-settings"
46
+ X-Frame-Options:
47
+ - DENY
48
+ X-Route:
49
+ - "/api/v1/project/:username/:repo/:build_num/tests"
50
+ - ":build_num"
51
+ - "\\d+"
52
+ Content-Length:
53
+ - '895'
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: !binary |-
59
+ H4sIAAAAAAAAANyZTW/bIBjHvwryuU1tx7GNb1u1w3bYqk07TVNECE5YCViA
60
+ 1aVVv/vAbpp2WmJo2sTeLcEPmB9/eF7MXaCJ0iooftwFStQSk6leVyQoAqkq
61
+ goOzYEWUQgvTwmvGzoKSMvvUPrzAVGJGMJ3afyM5M9btGE+6y5pPNV2ZpnAU
62
+ htkE5qaNqJppO0qNsRnemHFkTYLLZsRLCoRcIE5vkaaCA0l0LbkCCDCqNBCl
63
+ acGEazCrKZvb7pghpR7GaCbzbGrB/dlR6NIsHvvTqaWo2RzMCNh26AdPDiE8
64
+ hAdxQLnSiGNiRduYF8VXoirBFekFaTRKkg/niRMoFryki1q2pNgAWszGmswB
65
+ KjWRpoXyBVBE94UufRmdRtdEgRkT+BpoYYEeDN6Y66JWRLpv0knuBFcU382w
66
+ YPV4ykozgfWja1mtwRxptA9t9Divo/LlYeh0CDsAkfnVHjogZr8I3rs7Xw21
67
+ ksK+y8OF5nDiRnvVDm33pTYHTnViL5Fa7oV+Otljc8MsSd+I20HuU5KnMPYk
68
+ r3kpGBM3Q1d87JQKvYC734rHaR5HfuT/hd7j3Ck59Kbut9rGo7slxVtuwtGM
69
+ 7QhjeknAZi6g+ssV9nYNYOIb1fatwYC0n0BP327+IjnFCC93wTO20b3HeqeJ
70
+ p97d3IMRPYsmjhn5Br6t5qdtNT+dSVMwLrvVN/5RmmVpzfu6GpF1/G+2GkPZ
71
+ E1E0Tg9ZBcAFP691mRu/iMXc1tefvn35DCokbd2NhTTmmq37yh+mSZYdwj9g
72
+ VxjFjuWrD/lQNn6YZtBT+Ib7n8fefm4yhTkgvysizRu4Rgy8u/rYOML3thu4
73
+ QtKMq4ns74bIovDVVmSzHzi5sesjCdLGHTT2feU3ASH0zA26+Yd0HiaeGWFD
74
+ P3jZ43wcemZFe8AHo7cJ/K6fZzfYNqoNNtxFYe6b+e/mPZXI7Vd+1+uFce54
75
+ vVAUl83AgHKqKWL0ltjKXYE5KZHpCyoh9zM+mdhREbP4tRCXQh0LsY0a7mE5
76
+ dEzQ20QDSU1LZKuwnWd1a2Lzk27vvJ3wUcmjME4cM1Q3dK9jeyLoMIWuZWkL
77
+ bejk+kC/fCpWmEHH783drIMQN0tTx6uFFhjbG/qdUah96pRgnUzh1DHouvAO
78
+ QmHna9KWeEH0MA9vDGHuWC52kb5Y2J/3fwAAAP//AwCbqG4IJiUAAA==
79
+ http_version:
80
+ recorded_at: Sun, 29 Mar 2015 22:55:57 GMT
81
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+ require 'circle/cli/build'
3
+ require 'circle/cli/project'
4
+
5
+ module Circle::CLI
6
+ RSpec.describe Build do
7
+ let(:repo) {
8
+ instance_double('Repo', {
9
+ project: 'rb-array-sorting',
10
+ user_name: 'mtchavez',
11
+ branch_name: 'master',
12
+ circle_token: '123'
13
+ })
14
+ }
15
+
16
+ let(:project) { Project.new(repo) }
17
+ subject(:build) { Build.new(project, attrs) }
18
+ let(:attrs) { {} }
19
+
20
+ describe '#finished?' do
21
+ specify { is_expected.not_to be_finished }
22
+
23
+ context 'when finished' do
24
+ let(:attrs) { { 'outcome' => 'failed' }}
25
+ specify { is_expected.to be_finished }
26
+ end
27
+ end
28
+
29
+ describe '#failed?' do
30
+ specify { is_expected.not_to be_failed }
31
+
32
+ context 'when failed' do
33
+ let(:attrs) { { 'outcome' => 'failed' } }
34
+ specify { is_expected.to be_failed }
35
+ end
36
+ end
37
+
38
+ describe '#status' do
39
+ let(:attrs) { { 'status' => 'not_running' } }
40
+ specify { expect(build.status).to eq('Not running') }
41
+ end
42
+
43
+ describe '#subject' do
44
+ let(:attrs) { { 'subject' => ('s' * 52) }}
45
+ specify { expect(build.subject.length).to eq(50) }
46
+ end
47
+
48
+ describe '#color' do
49
+ let(:attrs) { { 'status' => 'failed' } }
50
+ specify { expect(build.color).to eq(:red) }
51
+ end
52
+
53
+ describe '#formatted_start_time' do
54
+ context 'when blank' do
55
+ specify { expect(build.formatted_start_time).to eq('Not started') }
56
+ end
57
+ end
58
+
59
+ describe '#formatted_stop_time' do
60
+ context 'when blank' do
61
+ specify { expect(build.formatted_stop_time).to eq('Not finished') }
62
+ end
63
+ end
64
+
65
+ describe '#tests', vcr: { cassette_name: 'tests' } do
66
+ let(:build) { Build.new(project, 'build_num' => 5) }
67
+
68
+ it 'returns a list of tests' do
69
+ expect(build.tests.length).to eq(39)
70
+ end
71
+
72
+ it 'caches the test results' do
73
+ expect(project).to receive(:request).once.and_call_original
74
+ build.tests
75
+ build.tests
76
+ end
77
+ end
78
+
79
+ describe '#passing_tests', vcr: { cassette_name: 'tests' } do
80
+ let(:build) { Build.new(project, 'build_num' => 5) }
81
+
82
+ it 'returns only passing specs' do
83
+ expect(build.passing_tests.length).to eq(39)
84
+ end
85
+ end
86
+
87
+ describe '#failing_tests', vcr: { cassette_name: 'tests' } do
88
+ let(:build) { Build.new(project, 'build_num' => 5) }
89
+
90
+ it 'returns only failing specs' do
91
+ expect(build.failing_tests.length).to eq(0)
92
+ end
93
+ end
94
+
95
+ describe '#details', vcr: { cassette_name: 'get' } do
96
+ let(:build) { Build.new(project, 'build_num' => 5) }
97
+
98
+ it 'caches the response' do
99
+ expect(project).to receive(:request).once.and_call_original
100
+ build.details
101
+ build.details
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+ require 'circle/cli/project'
3
+
4
+ module Circle::CLI
5
+ RSpec.describe Project do
6
+ let(:repo) {
7
+ instance_double('Repo', {
8
+ project: 'rb-array-sorting',
9
+ user_name: 'mtchavez',
10
+ branch_name: 'master',
11
+ circle_token: '123'
12
+ })
13
+ }
14
+
15
+ let(:project) {
16
+ Project.new(repo)
17
+ }
18
+
19
+ describe '#builds', vcr: { cassette_name: 'recent_builds_branch' } do
20
+ subject { project.builds }
21
+ specify { is_expected.not_to be_empty }
22
+ end
23
+
24
+ describe '#recent_builds', vcr: { cassette_name: 'recent_builds' } do
25
+ subject { project.recent_builds }
26
+ specify { is_expected.not_to be_empty }
27
+ end
28
+
29
+ describe '#latest', vcr: { cassette_name: 'recent_builds_branch' } do
30
+ subject { project.latest['status'] }
31
+ specify { is_expected.to eq('no_tests') }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'circle/cli/repo'
3
+
4
+ module Circle::CLI
5
+ RSpec.describe Repo do
6
+ let(:options) { {} }
7
+ let(:repo) { Repo.new(options) }
8
+ let(:uri) { 'git@github.com:organization/repo.git' }
9
+
10
+ let(:origin) {
11
+ double('remote', name: 'origin', url: uri)
12
+ }
13
+
14
+ let(:git) {
15
+ instance_double('Rugged::Repository', {
16
+ config: {'circleci.token' => '123' },
17
+ remotes: [origin]
18
+ })
19
+ }
20
+
21
+ before do
22
+ allow(repo).to receive(:repo).and_return(git)
23
+ end
24
+
25
+ describe '#uri' do
26
+ subject { repo.uri }
27
+ specify { is_expected.to be_github }
28
+ end
29
+
30
+ describe '#user_name' do
31
+ subject { repo.user_name }
32
+ specify { is_expected.to eq('organization') }
33
+ end
34
+
35
+ describe '#project' do
36
+ subject { repo.project }
37
+ specify { is_expected.to eq('repo') }
38
+ end
39
+
40
+ describe '#branch_name' do
41
+ subject { repo.branch_name }
42
+
43
+ context 'when :branch is provided' do
44
+ let(:options) { { 'branch' => 'option' } }
45
+ specify { is_expected.to eq('option') }
46
+ end
47
+
48
+ context 'when :branch isnt provided' do
49
+ let(:head) { double('head', name: 'refs/heads/bug/jawn') }
50
+ before { allow(git).to receive(:head).and_return(head) }
51
+ specify { is_expected.to eq('bug/jawn') }
52
+ end
53
+ end
54
+
55
+ describe '#circle_token' do
56
+ subject { repo.circle_token }
57
+ specify { is_expected.to eq('123') }
58
+ end
59
+
60
+ describe '#circle_token=' do
61
+ subject { repo.circle_token }
62
+ before { repo.circle_token = '456' }
63
+ specify { is_expected.to eq('456') }
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'circle/cli/step'
3
+
4
+ module Circle::CLI
5
+ RSpec.describe Step do
6
+ let(:step) { Step.new(attrs) }
7
+
8
+ describe '#color' do
9
+ let(:attrs) {
10
+ { 'actions' => [{ 'status' => 'failed' }] }
11
+ }
12
+
13
+ specify { expect(step.color).to eq(:red) }
14
+ end
15
+
16
+ describe '#duration' do
17
+ subject { step.duration }
18
+ let(:attrs) { { 'run_time_millis' => millis } }
19
+
20
+ context 'hours' do
21
+ let(:millis) { 10_000_000 }
22
+ specify { is_expected.to eq('2h 46m 40s') }
23
+ end
24
+
25
+ context 'minutes' do
26
+ let(:millis) { 1_000_000 }
27
+ specify { is_expected.to eq('16m 40s') }
28
+ end
29
+
30
+ context 'seconds' do
31
+ let(:millis) { 2_000 }
32
+ specify { is_expected.to eq('2s') }
33
+ end
34
+
35
+ context 'milliseconds' do
36
+ let(:millis) { 200 }
37
+ specify { is_expected.to eq('200ms') }
38
+ end
39
+ end
40
+ end
41
+ end
@@ -4,8 +4,19 @@
4
4
  # loaded once.
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'vcr'
8
+ require 'webmock/rspec'
9
+ require 'simplecov'
10
+
11
+ SimpleCov.start
12
+
13
+ VCR.configure do |config|
14
+ config.cassette_library_dir = File.expand_path('../cassettes', __FILE__)
15
+ config.hook_into :webmock
16
+ config.configure_rspec_metadata!
17
+ end
18
+
7
19
  RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
20
  config.run_all_when_everything_filtered = true
10
21
  config.filter_run :focus
11
22
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circle-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Derek Keith
7
8
  - Jean Boussier
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-01-30 00:00:00.000000000 Z
12
+ date: 2016-03-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: circleci
@@ -39,7 +40,35 @@ dependencies:
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0.23'
41
42
  - !ruby/object:Gem::Dependency
42
- name: octokit
43
+ name: gitable
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: launchy
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: thor
43
72
  requirement: !ruby/object:Gem::Requirement
44
73
  requirements:
45
74
  - - '>='
@@ -94,9 +123,52 @@ dependencies:
94
123
  - - '>='
95
124
  - !ruby/object:Gem::Version
96
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: vcr
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: webmock
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: simplecov
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
97
168
  description: A bunch of commands useful to deal with Circle CI without leaving your
98
169
  terminal.
99
170
  email:
171
+ - derek@codeurge.com
100
172
  - jean.boussier@gmail.com
101
173
  executables:
102
174
  - circle
@@ -114,7 +186,21 @@ files:
114
186
  - circle-cli.gemspec
115
187
  - lib/circle-cli.rb
116
188
  - lib/circle/cli.rb
189
+ - lib/circle/cli/app.rb
190
+ - lib/circle/cli/build.rb
191
+ - lib/circle/cli/model.rb
192
+ - lib/circle/cli/project.rb
193
+ - lib/circle/cli/repo.rb
194
+ - lib/circle/cli/step.rb
117
195
  - lib/circle/cli/version.rb
196
+ - spec/cassettes/get.yml
197
+ - spec/cassettes/recent_builds.yml
198
+ - spec/cassettes/recent_builds_branch.yml
199
+ - spec/cassettes/tests.yml
200
+ - spec/circle/cli/build_spec.rb
201
+ - spec/circle/cli/project_spec.rb
202
+ - spec/circle/cli/repo_spec.rb
203
+ - spec/circle/cli/step_spec.rb
118
204
  - spec/spec_helper.rb
119
205
  homepage: ''
120
206
  licenses:
@@ -141,4 +227,12 @@ signing_key:
141
227
  specification_version: 4
142
228
  summary: Command line tools for Circle CI
143
229
  test_files:
230
+ - spec/cassettes/get.yml
231
+ - spec/cassettes/recent_builds.yml
232
+ - spec/cassettes/recent_builds_branch.yml
233
+ - spec/cassettes/tests.yml
234
+ - spec/circle/cli/build_spec.rb
235
+ - spec/circle/cli/project_spec.rb
236
+ - spec/circle/cli/repo_spec.rb
237
+ - spec/circle/cli/step_spec.rb
144
238
  - spec/spec_helper.rb