kapnismology 2.2.0 → 2.2.1

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
  SHA1:
3
- metadata.gz: 4339000a844a6c3f722b1980f8e70a5acc78f5e5
4
- data.tar.gz: fb8b3a15c6d841d73b5f9d1198188e8e4e1aa572
3
+ metadata.gz: 51c9bd5b25a2eff1be770baeb7ca2046f757e589
4
+ data.tar.gz: 8d7d741333c07ec96c7dee8b88ccede3ce5c10f5
5
5
  SHA512:
6
- metadata.gz: 4de8ef415f02d7234ba102f235f1f9628822f531b130b7078ae19fc459f503b1a1de8ccfd9d67549be172af447e22a3c35b9b351fb1cf3ace851e52bfc09e954
7
- data.tar.gz: 3ac836944d8c79fd3694b7f3f631c104d921d0df3e938e8c1aa898c921498e9f219b3d69af9fa97a9f3ce3577ffd739b8f9dac10ee91e618053ac39dea9c9ea6
6
+ metadata.gz: 6fa2922b7ec761a04001292743ce4695a8cba5d504c55936a4c28a026fe7ebddd12cbfe8b4fe3f15bb27c5cec8336058a0d9f54431b7afcf6669bb378d8d2a51
7
+ data.tar.gz: 5ee7a610033ee55a7a3d025331baeba88bb93fbb059d03ed01c0e59b44ff7853087ccb236a03a2f3abdbac23b7349087be0bccc66ff9fbbba036c268129e90db
@@ -2,11 +2,10 @@ module Kapnismology
2
2
  # This is called when the user goes to the /smoke_test URL. This calls all the
3
3
  # smoke tests registered in the application and gather the results
4
4
  class SmokeTestsController < ApplicationController
5
- PROFILE_URL = 'http://tbd.mdsol.com'.freeze
6
5
 
7
6
  def index
8
- evaluations = SmokeTestCollection.evaluations(allowed_tags, blacklist)
9
- render json: results(evaluations).to_json, status: status(evaluations)
7
+ response = SmokeTestResponse.new(SmokeTestCollection.evaluations(allowed_tags, blacklist))
8
+ render json: response.render(request.original_url), status: response.status
10
9
  end
11
10
 
12
11
  private
@@ -18,29 +17,6 @@ module Kapnismology
18
17
  def blacklist
19
18
  params[:skip].to_s.split(',')
20
19
  end
21
-
22
- def status(evaluations)
23
- if evaluations.passed?
24
- :ok
25
- else
26
- :service_unavailable
27
- end
28
- end
29
-
30
- def results(evaluations)
31
- items = evaluations.as_json.select { |e| e.has_key?(:passed) }
32
- {
33
- _links: {
34
- self: CGI.unescape(request.original_url),
35
- profile: PROFILE_URL
36
- },
37
- passed: evaluations.passed?,
38
- count: items.size,
39
- trace_id: ApplicationInformation.new.trace_id,
40
- codebase_revision: ApplicationInformation.new.codebase_revision,
41
- items: items
42
- }
43
- end
44
20
  end
45
21
 
46
22
  end
data/lib/kapnismology.rb CHANGED
@@ -7,4 +7,5 @@ require 'kapnismology/evaluation_collection'
7
7
  require 'kapnismology/rake_task'
8
8
  require 'kapnismology/smoke_test'
9
9
  require 'kapnismology/smoke_test_collection'
10
+ require 'kapnismology/smoke_test_response'
10
11
  require 'kapnismology/spec_helper'
@@ -14,7 +14,7 @@ module Kapnismology
14
14
  @result.passed?
15
15
  end
16
16
 
17
- def as_json(_options = nil)
17
+ def to_hash(_options = nil)
18
18
  { name: @name.underscore }.merge(@result.to_hash)
19
19
  end
20
20
 
@@ -19,8 +19,8 @@ module Kapnismology
19
19
  evaluations.all?(&:passed?)
20
20
  end
21
21
 
22
- def to_json
23
- evaluations.map { |evaluation| evaluation.as_json }.to_json
22
+ def to_hash
23
+ evaluations.map(&:to_hash)
24
24
  end
25
25
 
26
26
  private
@@ -0,0 +1,31 @@
1
+ module Kapnismology
2
+ # A summary of a run containing smoke test evaluations
3
+ class SmokeTestResponse
4
+
5
+ PROFILE_URL = 'http://tbd.mdsol.com'.freeze
6
+
7
+ def initialize(evaluations)
8
+ @evaluations = evaluations
9
+ end
10
+
11
+ def status
12
+ @evaluations.passed? ? 200 : 503
13
+ end
14
+
15
+ def render(request_url)
16
+ items = @evaluations.to_hash.select { |e| e.has_key?(:passed) }
17
+ {
18
+ _links: {
19
+ self: CGI.unescape(request_url),
20
+ profile: PROFILE_URL
21
+ },
22
+ passed: @evaluations.passed?,
23
+ count: items.size,
24
+ trace_id: ApplicationInformation.new.trace_id,
25
+ codebase_revision: ApplicationInformation.new.codebase_revision,
26
+ items: items
27
+ }.to_json
28
+ end
29
+
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Kapnismology
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapnismology
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordi Polo Carres
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-json_expectations
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: byebug
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +171,7 @@ files:
157
171
  - lib/kapnismology/smoke_test.rb
158
172
  - lib/kapnismology/smoke_test_collection.rb
159
173
  - lib/kapnismology/smoke_test_failed.rb
174
+ - lib/kapnismology/smoke_test_response.rb
160
175
  - lib/kapnismology/spec_helper.rb
161
176
  - lib/kapnismology/terminal.rb
162
177
  - lib/kapnismology/version.rb