knapsack_pro 0.57.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 653d33cf8cec36e3f29ba1e3f5c1fd2ccd791e2c5f28dc9f902c61f634f6b881
4
- data.tar.gz: 838eef54f03ff2bc88d0c4553ff0c535fd232f9aa7986e4ecac8734cbc297e25
3
+ metadata.gz: 6a9d12ed730f59a34f2fe1842ac39d712275f72fe292cc870f77596d899ee100
4
+ data.tar.gz: f246cb0437c435f76c3540a4b789098c7249dff4acc9263a361a90712e3e1ddb
5
5
  SHA512:
6
- metadata.gz: c969994628a4db7b5f55f97260902a8d5e7ee76396db08103592daeec3a391ff92ac1b3b0a00f32ab0af6e46f50d07b7a688feb3675a21f500bb207d919e1c83
7
- data.tar.gz: 5c188e1d96c4caf3274cfff5c8f791e6a243d67d3abd7ad30f9ebb4c7b3e851be8f227ec86dcc4be0dbabc563e2c108d4e43832b1a3826a9935e0ef9e6519fc1
6
+ metadata.gz: c7476ae1b247a4ebe47bc0af7cf982b290021d5a566668873db9784b25e38bc32ae14bd511082b53e2a3c4f26153fc7b4f642a2c0ae0469cf1d2eeb1b6975794
7
+ data.tar.gz: ecf515f604be60a9e44906eeddb4292222c6af02a427fd1e73bfc69ac9234e5af02dc9b67ae933b2d462582bac9ae599e32c4e3c713c0ac553ebef44aa30f2fe
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 1.0.0
6
+
7
+ * Release 1.0.0 is backward compatible with all previous releases.
8
+ * Run tests in Fallback Mode when API response is 5xx
9
+
10
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/69
11
+
12
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.57.0...v1.0.0
13
+
5
14
  ### 0.57.0
6
15
 
7
16
  * Add support for Solano CI and AppVeyor
data/README.md CHANGED
@@ -166,6 +166,7 @@ The knapsack_pro has also [queue mode](#queue-mode) to get an optimal test suite
166
166
  - [Gem tests](#gem-tests)
167
167
  - [Spec](#spec)
168
168
  - [Contributing](#contributing)
169
+ - [Publishing](#publishing)
169
170
  - [Mentions](#mentions)
170
171
 
171
172
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -773,7 +774,7 @@ end
773
774
 
774
775
  #### Info for Travis users
775
776
 
776
- You can parallelize your builds across virtual machines with [travis matrix feature](http://docs.travis-ci.com/user/speeding-up-the-build/#Parallelizing-your-builds-across-virtual-machines). Edit `.travis.yml`
777
+ You can parallelize your builds across virtual machines with [travis matrix feature](http://docs.travis-ci.com/user/speeding-up-the-build/#parallelizing-your-builds-across-virtual-machines). Edit `.travis.yml`
777
778
 
778
779
  ```yaml
779
780
  script:
@@ -812,7 +813,7 @@ Such configuration will generate matrix with 2 following ENV rows:
812
813
  KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT=test-unit-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
813
814
  KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT=test-unit-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
814
815
 
815
- More info about global and matrix ENV configuration in [travis docs](https://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix).
816
+ More info about global and matrix ENV configuration in [travis docs](https://docs.travis-ci.com/user/customizing-the-build/#build-matrix).
816
817
 
817
818
  #### Info for semaphoreapp.com users
818
819
 
@@ -1945,6 +1946,29 @@ To run specs for Knapsack Pro gem type:
1945
1946
  5. You can create example tests in related repository with example of [rails application and knapsack_pro gem usage](https://github.com/KnapsackPro/rails-app-with-knapsack_pro).
1946
1947
  6. Create a new Pull Request
1947
1948
 
1949
+ ### Publishing
1950
+
1951
+ Update version in `lib/knapsack_pro/version.rb` and `CHANGELOG.md`:
1952
+
1953
+ ```
1954
+ $ git commit -m "Bump version X.X.X"
1955
+ $ git push origin master
1956
+ ```
1957
+
1958
+ Create git tag for release:
1959
+
1960
+ ```
1961
+ $ git tag -a vX.X.X -m "Release vX.X.X"
1962
+ $ git push --tags
1963
+ ```
1964
+
1965
+ Build gem and publish it to RubyGems.org:
1966
+
1967
+ ```
1968
+ $ gem build knapsack_pro.gemspec
1969
+ $ gem push knapsack_pro-X.X.X.gem
1970
+ ```
1971
+
1948
1972
  ## Mentions
1949
1973
 
1950
1974
  List of articles where people mentioned Knapsack Pro:
@@ -13,16 +13,19 @@ module KnapsackPro
13
13
  end
14
14
 
15
15
  def success?
16
- !!response
16
+ return false if !response_body
17
+
18
+ status = http_response.code.to_i
19
+ status >= 200 && status < 500
17
20
  end
18
21
 
19
22
  def errors?
20
- !!(response && (response['errors'] || response['error']))
23
+ !!(response_body && (response_body['errors'] || response_body['error']))
21
24
  end
22
25
 
23
26
  private
24
27
 
25
- attr_reader :action, :response
28
+ attr_reader :action, :http_response, :response_body
26
29
 
27
30
  def logger
28
31
  KnapsackPro.logger
@@ -61,7 +64,7 @@ module KnapsackPro
61
64
  }
62
65
  end
63
66
 
64
- def parse_response(body)
67
+ def parse_response_body(body)
65
68
  return '' if body == '' || body.nil?
66
69
  JSON.parse(body)
67
70
  rescue JSON::ParserError
@@ -69,8 +72,8 @@ module KnapsackPro
69
72
  end
70
73
 
71
74
  def seed
72
- return if @response.nil? || @response == ''
73
- response['build_distribution_id']
75
+ return if @response_body.nil? || @response_body == ''
76
+ response_body['build_distribution_id']
74
77
  end
75
78
 
76
79
  def has_seed?
@@ -85,8 +88,8 @@ module KnapsackPro
85
88
  http.open_timeout = TIMEOUT
86
89
  http.read_timeout = TIMEOUT
87
90
 
88
- http_response = http.post(uri.path, request_body, json_headers)
89
- @response = parse_response(http_response.body)
91
+ @http_response = http.post(uri.path, request_body, json_headers)
92
+ @response_body = parse_response_body(http_response.body)
90
93
 
91
94
  request_uuid = http_response.header['X-Request-Id']
92
95
 
@@ -94,12 +97,12 @@ module KnapsackPro
94
97
  logger.debug("Test suite split seed: #{seed}") if has_seed?
95
98
  logger.debug('API response:')
96
99
  if errors?
97
- logger.error(response)
100
+ logger.error(response_body)
98
101
  else
99
- logger.debug(response)
102
+ logger.debug(response_body)
100
103
  end
101
104
 
102
- response
105
+ response_body
103
106
  rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, EOFError, SocketError, Net::OpenTimeout, Net::ReadTimeout => e
104
107
  logger.warn(e.inspect)
105
108
  retries += 1
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '0.57.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -34,7 +34,7 @@ describe KnapsackPro::Client::Connection do
34
34
  expect(http).to receive(:read_timeout=).with(15)
35
35
 
36
36
  header = { 'X-Request-Id' => 'fake-uuid' }
37
- http_response = instance_double(Net::HTTPOK, body: body, header: header)
37
+ http_response = instance_double(Net::HTTPOK, body: body, header: header, code: code)
38
38
  expect(http).to receive(:post).with(
39
39
  endpoint_path,
40
40
  "{\"fake\":\"hash\",\"test_suite_token\":\"3fa64859337f6e56409d49f865d13fd7\"}",
@@ -47,8 +47,9 @@ describe KnapsackPro::Client::Connection do
47
47
  ).and_return(http_response)
48
48
  end
49
49
 
50
- context 'when body response is json' do
50
+ context 'when body response is json and API response code is 400' do
51
51
  let(:body) { '{"errors": "value"}' }
52
+ let(:code) { '400' } # it must be string code
52
53
 
53
54
  before do
54
55
  expect(KnapsackPro).to receive(:logger).exactly(3).and_return(logger)
@@ -67,8 +68,30 @@ describe KnapsackPro::Client::Connection do
67
68
  end
68
69
  end
69
70
 
71
+ context 'when body response is json and API response code is 500' do
72
+ let(:body) { '{"error": "Internal Server Error"}' }
73
+ let(:code) { '500' } # it must be string code
74
+
75
+ before do
76
+ expect(KnapsackPro).to receive(:logger).exactly(3).and_return(logger)
77
+ expect(logger).to receive(:debug).with('API request UUID: fake-uuid')
78
+ expect(logger).to receive(:debug).with('API response:')
79
+ end
80
+
81
+ it do
82
+ parsed_response = { 'error' => 'Internal Server Error' }
83
+
84
+ expect(logger).to receive(:error).with(parsed_response)
85
+
86
+ expect(subject).to eq(parsed_response)
87
+ expect(connection.success?).to be false
88
+ expect(connection.errors?).to be true
89
+ end
90
+ end
91
+
70
92
  context 'when body response is json with build_distribution_id' do
71
93
  let(:body) { '{"build_distribution_id": "seed-uuid"}' }
94
+ let(:code) { '200' } # it must be string code
72
95
 
73
96
  before do
74
97
  expect(KnapsackPro).to receive(:logger).exactly(4).and_return(logger)
@@ -90,6 +113,7 @@ describe KnapsackPro::Client::Connection do
90
113
 
91
114
  context 'when body response is empty' do
92
115
  let(:body) { '' }
116
+ let(:code) { '200' } # it must be string code
93
117
 
94
118
  before do
95
119
  expect(KnapsackPro).to receive(:logger).exactly(3).and_return(logger)
@@ -112,21 +136,48 @@ describe KnapsackPro::Client::Connection do
112
136
  subject { connection.success? }
113
137
 
114
138
  before do
115
- allow(connection).to receive(:response).and_return(response)
139
+ allow(connection).to receive(:response_body).and_return(response_body)
116
140
  end
117
141
 
118
142
  context 'when response has no value' do
119
- let(:response) { nil }
143
+ let(:response_body) { nil }
120
144
 
121
145
  it { should be false }
122
146
  end
123
147
 
124
148
  context 'when response has value' do
125
- let(:response) do
149
+ let(:response_body) do
126
150
  { 'fake' => 'response' }
127
151
  end
128
152
 
129
- it { should be true }
153
+ before do
154
+ http_response = double(code: code)
155
+ allow(connection).to receive(:http_response).and_return(http_response)
156
+ end
157
+
158
+ context 'when response code is 200' do
159
+ let(:code) { '200' } # it must be string code
160
+
161
+ it { should be true }
162
+ end
163
+
164
+ context 'when response code is 300' do
165
+ let(:code) { '300' } # it must be string code
166
+
167
+ it { should be true }
168
+ end
169
+
170
+ context 'when response code is 400' do
171
+ let(:code) { '400' } # it must be string code
172
+
173
+ it { should be true }
174
+ end
175
+
176
+ context 'when response code is 500' do
177
+ let(:code) { '500' } # it must be string code
178
+
179
+ it { should be false }
180
+ end
130
181
  end
131
182
  end
132
183
 
@@ -134,18 +185,18 @@ describe KnapsackPro::Client::Connection do
134
185
  subject { connection.errors? }
135
186
 
136
187
  before do
137
- allow(connection).to receive(:response).and_return(response)
188
+ allow(connection).to receive(:response_body).and_return(response_body)
138
189
  end
139
190
 
140
191
  context 'when response has no value' do
141
- let(:response) { nil }
192
+ let(:response_body) { nil }
142
193
 
143
194
  it { should be false }
144
195
  end
145
196
 
146
197
  context 'when response has value' do
147
198
  context 'when response has no errors' do
148
- let(:response) do
199
+ let(:response_body) do
149
200
  { 'fake' => 'response' }
150
201
  end
151
202
 
@@ -153,7 +204,7 @@ describe KnapsackPro::Client::Connection do
153
204
  end
154
205
 
155
206
  context 'when response has errors' do
156
- let(:response) do
207
+ let(:response_body) do
157
208
  { 'errors' => [{ 'field' => 'is wrong' }] }
158
209
  end
159
210
 
@@ -161,7 +212,7 @@ describe KnapsackPro::Client::Connection do
161
212
  end
162
213
 
163
214
  context 'when response has error (i.e. internal server error)' do
164
- let(:response) do
215
+ let(:response_body) do
165
216
  { 'error' => 'Internal Server Error' }
166
217
  end
167
218
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.57.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-06 00:00:00.000000000 Z
11
+ date: 2018-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake