outliers 0.5.1 → 0.6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -0
- data/lib/outliers/cli/process.rb +5 -4
- data/lib/outliers/collection.rb +10 -11
- data/lib/outliers/evaluation.rb +2 -2
- data/lib/outliers/result.rb +7 -14
- data/lib/outliers/run.rb +0 -8
- data/lib/outliers/verifications.rb +1 -1
- data/lib/outliers/verifications/collection/shared.rb +23 -0
- data/lib/outliers/verifications/shared/collection.rb +26 -0
- data/lib/outliers/version.rb +1 -1
- data/spec/collection_spec.rb +18 -8
- data/spec/evaluation_spec.rb +11 -11
- data/spec/info_spec.rb +1 -1
- data/spec/results_spec.rb +14 -13
- data/spec/run_spec.rb +0 -22
- data/spec/verifications/shared_spec.rb +20 -15
- metadata +4 -3
- data/lib/outliers/verifications/shared.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f647b789982e7cd060e71a05b4fc7380a6ef8340
|
4
|
+
data.tar.gz: 8c2d681037ca9bb6b1082ca1a6f30f6115c74990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 127b3a230b8eb7202dab2d45303107bca054ad1ea6217ed5b126f914937f9b1c568ab61133738277ed4dbcab1884ec6b5dc77748104b8f4ecd2e843abf4dfc7e
|
7
|
+
data.tar.gz: b0fa65e503778c676f4586e97f4b3b9f9cdb605422e341e8ad44998fcaaffa07ffc0522f4ec4bac50221487c835a4458ab6176ae824142d2fc3e32de294715a3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -63,3 +63,7 @@ See [examples](http://www.getoutliers.com/documentation/examples) for a list of
|
|
63
63
|
## Documentation
|
64
64
|
|
65
65
|
See more information on the Outliers DSL see the [documentation](http://www.getoutliers.com/documentation) page.
|
66
|
+
|
67
|
+
## Attribution
|
68
|
+
|
69
|
+
Based on [sanity](https://github.com/brettweavnet/sanity).
|
data/lib/outliers/cli/process.rb
CHANGED
@@ -33,8 +33,8 @@ module Outliers
|
|
33
33
|
exit 1
|
34
34
|
end
|
35
35
|
|
36
|
-
passing_count = @run.
|
37
|
-
failing_count = @run.
|
36
|
+
passing_count = @run.results.select {|r| r.passed? }.count
|
37
|
+
failing_count = @run.results.select {|r| r.failed? }.count
|
38
38
|
|
39
39
|
@logger.info "Evaluations completed."
|
40
40
|
|
@@ -51,13 +51,14 @@ module Outliers
|
|
51
51
|
@logger.info "OUTLIERS_KEY not set, not sending results."
|
52
52
|
end
|
53
53
|
|
54
|
-
@run.
|
54
|
+
failed_results = @run.results.select {|r| r.failed? }
|
55
|
+
|
56
|
+
failed_results.each do |r|
|
55
57
|
if r.name
|
56
58
|
@logger.info "Results of '#{r.name}', verifying '#{r.verification_name}' of '#{r.provider_name}:#{r.resource_name}' via '#{r.account_name}' failed."
|
57
59
|
else
|
58
60
|
@logger.info "Verification '#{r.verification_name}' of '#{r.provider_name}:#{r.resource_name}' via '#{r.account_name}' failed."
|
59
61
|
end
|
60
|
-
@logger.info "Failing resource IDs '#{r.failing_resources.map{|r| r.id}.join(', ')}'"
|
61
62
|
end
|
62
63
|
|
63
64
|
@logger.info "(#{failing_count} evaluations failed, #{passing_count} evaluations passed.)"
|
data/lib/outliers/collection.rb
CHANGED
@@ -4,7 +4,7 @@ module Outliers
|
|
4
4
|
class Collection
|
5
5
|
|
6
6
|
include Enumerable
|
7
|
-
include Outliers::Verifications::Shared
|
7
|
+
include Outliers::Verifications::Shared::Collection
|
8
8
|
|
9
9
|
attr_reader :provider
|
10
10
|
attr_accessor :targets
|
@@ -14,7 +14,7 @@ module Outliers
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.verifications
|
17
|
-
Outliers::Verifications::Shared.verifications + self.resource_class.verifications
|
17
|
+
Outliers::Verifications::Shared::Collection.verifications + self.resource_class.verifications
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.filters
|
@@ -60,7 +60,7 @@ module Outliers
|
|
60
60
|
case action
|
61
61
|
when 'include'
|
62
62
|
logger.info "Including resources filtered by '#{name}' with value '#{value}'."
|
63
|
-
logger.warn "No resources match filter." unless filtered_list.any?
|
63
|
+
logger.warn "No resources match filter." unless (filtered_list & @list).any?
|
64
64
|
@list = filtered_list & @list
|
65
65
|
when 'exclude'
|
66
66
|
logger.info "Excluding resources filtered by '#{name}' with value '#{value}'."
|
@@ -75,10 +75,6 @@ module Outliers
|
|
75
75
|
|
76
76
|
name += "?" unless name =~ /^.*\?$/
|
77
77
|
|
78
|
-
unless list.any?
|
79
|
-
return { failing_resources: [], passing_resources: [] }
|
80
|
-
end
|
81
|
-
|
82
78
|
set_target_resources name if targets.any?
|
83
79
|
|
84
80
|
logger.debug "Target resources '#{list_by_key.join(', ')}'."
|
@@ -110,7 +106,7 @@ module Outliers
|
|
110
106
|
|
111
107
|
def verification_exists?(name)
|
112
108
|
m = resource_class.instance_methods - resource_class.class.instance_methods
|
113
|
-
m += Outliers::Verifications::Shared.instance_methods
|
109
|
+
m += Outliers::Verifications::Shared::Collection.instance_methods
|
114
110
|
m -= [:source, :id, :method_missing]
|
115
111
|
m.include? name.to_sym
|
116
112
|
end
|
@@ -149,12 +145,15 @@ module Outliers
|
|
149
145
|
logger.debug "Verification of resource '#{resource.id}' #{r ? 'passed' : 'failed'}."
|
150
146
|
r
|
151
147
|
end
|
152
|
-
|
148
|
+
passing_resources = list - failing_resources
|
149
|
+
resources = []
|
150
|
+
resources += passing_resources.map { |r| { id: r.id, status: 0 } }
|
151
|
+
resources += failing_resources.map { |r| { id: r.id, status: 1 } }
|
152
|
+
{ resources: resources, passing: failing_resources.none? }
|
153
153
|
end
|
154
154
|
|
155
155
|
def send_collection_verification(verification, arguments)
|
156
|
-
|
157
|
-
{ failing_resources: failing_resources, passing_resources: list - failing_resources }
|
156
|
+
send_verification self, verification, arguments
|
158
157
|
end
|
159
158
|
|
160
159
|
def send_verification(object, verification, arguments)
|
data/lib/outliers/evaluation.rb
CHANGED
@@ -42,9 +42,9 @@ module Outliers
|
|
42
42
|
verification_result = resource_collection.verify verification_name, args_to_send
|
43
43
|
|
44
44
|
result = Outliers::Result.new account_name: @account_name,
|
45
|
-
|
45
|
+
resources: verification_result.fetch(:resources),
|
46
|
+
passing: verification_result.fetch(:passing),
|
46
47
|
name: @name,
|
47
|
-
passing_resources: verification_result.fetch(:passing_resources),
|
48
48
|
arguments: Array(args_to_send),
|
49
49
|
provider_name: @provider_name,
|
50
50
|
resource_name: @resource_name,
|
data/lib/outliers/result.rb
CHANGED
@@ -3,8 +3,8 @@ require 'json'
|
|
3
3
|
module Outliers
|
4
4
|
class Result
|
5
5
|
|
6
|
-
attr_reader :account_name, :arguments, :
|
7
|
-
:provider_name, :resource_name, :verification_name
|
6
|
+
attr_reader :account_name, :arguments, :name, :passing,
|
7
|
+
:provider_name, :resources, :resource_name, :verification_name
|
8
8
|
|
9
9
|
def to_json
|
10
10
|
to_hash.to_json
|
@@ -14,6 +14,7 @@ module Outliers
|
|
14
14
|
{ 'account_name' => account_name,
|
15
15
|
'arguments' => arguments,
|
16
16
|
'name' => name,
|
17
|
+
'passing' => passing,
|
17
18
|
'provider_name' => provider_name,
|
18
19
|
'resource_name' => resource_name,
|
19
20
|
'verification_name' => verification_name,
|
@@ -23,28 +24,20 @@ module Outliers
|
|
23
24
|
def initialize(args)
|
24
25
|
@account_name = args[:account_name]
|
25
26
|
@arguments = args[:arguments]
|
26
|
-
@failing_resources = args[:failing_resources]
|
27
27
|
@name = args[:name] || 'unspecified'
|
28
|
-
@passing_resources = args[:passing_resources]
|
29
28
|
@provider_name = args[:provider_name]
|
29
|
+
@resources = args[:resources]
|
30
30
|
@resource_name = args[:resource_name]
|
31
|
+
@passing = args[:passing]
|
31
32
|
@verification_name = args[:verification_name]
|
32
33
|
end
|
33
34
|
|
34
35
|
def passed?
|
35
|
-
|
36
|
+
@passing
|
36
37
|
end
|
37
38
|
|
38
39
|
def failed?
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def resources
|
45
|
-
r = passing_resources.map{|r| { 'id' => r.id, 'passing' => 1 } }
|
46
|
-
r += failing_resources.map{|r| { 'id' => r.id, 'passing' => 0 } }
|
47
|
-
r
|
40
|
+
!passed?
|
48
41
|
end
|
49
42
|
|
50
43
|
end
|
data/lib/outliers/run.rb
CHANGED
@@ -38,14 +38,6 @@ module Outliers
|
|
38
38
|
threaded ? threads << Thread.new { evaluation.call } : evaluation.call
|
39
39
|
end
|
40
40
|
|
41
|
-
def passing_results
|
42
|
-
@results.select {|r| r.passed?}
|
43
|
-
end
|
44
|
-
|
45
|
-
def failing_results
|
46
|
-
@results.reject {|r| r.passed?}
|
47
|
-
end
|
48
|
-
|
49
41
|
private
|
50
42
|
|
51
43
|
def files
|
@@ -1 +1 @@
|
|
1
|
-
require 'outliers/verifications/shared'
|
1
|
+
require 'outliers/verifications/shared/collection'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Outliers
|
2
|
+
module Verifications
|
3
|
+
module Collection
|
4
|
+
module Shared
|
5
|
+
|
6
|
+
def none_exist?
|
7
|
+
resources = {}
|
8
|
+
list.each {|r| resources.merge! id: r, status: 2}
|
9
|
+
{ resources: resources, passing: resources.any? }
|
10
|
+
end
|
11
|
+
|
12
|
+
def equals?(args)
|
13
|
+
keys = Array(args)
|
14
|
+
logger.debug "Verifying '#{keys.join(',')}' equals '#{list.empty? ? 'no resources' : list_by_key.join(',')}'."
|
15
|
+
resources = {}
|
16
|
+
list.each {|r| resources.merge! id: r, status: 2}
|
17
|
+
{ resources: resources, passing: FIXME_WITH_EQUALS_LOGIC }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Outliers
|
2
|
+
module Verifications
|
3
|
+
module Shared
|
4
|
+
module Collection
|
5
|
+
|
6
|
+
def none_exist?
|
7
|
+
resources = list.map do |r|
|
8
|
+
{ id: r.id, status: 2 }
|
9
|
+
end
|
10
|
+
{ resources: resources, passing: resources.none? }
|
11
|
+
end
|
12
|
+
|
13
|
+
def equals?(args)
|
14
|
+
keys = Array(args)
|
15
|
+
logger.debug "Verifying '#{keys.join(',')}' equals '#{list.empty? ? 'no resources' : list_by_key.join(',')}'."
|
16
|
+
resources = list.map do |r|
|
17
|
+
{ id: r.id, status: 2 }
|
18
|
+
end
|
19
|
+
passing = (list.map{|r| r.id} == keys)
|
20
|
+
{ resources: resources, passing: passing }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/outliers/version.rb
CHANGED
data/spec/collection_spec.rb
CHANGED
@@ -36,6 +36,10 @@ describe Outliers::Collection do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
context "#verifications" do
|
40
|
+
it "should return the shared and collection verifications"
|
41
|
+
end
|
42
|
+
|
39
43
|
context "#filter" do
|
40
44
|
before do
|
41
45
|
subject.instance_variable_set(:@list, [resource1, resource2, resource3])
|
@@ -114,7 +118,8 @@ describe Outliers::Collection do
|
|
114
118
|
|
115
119
|
it "should verify the given verification against the colection" do
|
116
120
|
expect(subject.verify 'none_exist?').
|
117
|
-
to eq( {
|
121
|
+
to eq({ resources: [{ id: "resource1", status: 2 },
|
122
|
+
{ id: "resource2", status: 2 }], passing: false })
|
118
123
|
end
|
119
124
|
|
120
125
|
it "should raise unkown verification if the verification does not exist" do
|
@@ -123,18 +128,21 @@ describe Outliers::Collection do
|
|
123
128
|
|
124
129
|
it "should verify the given verification against the colection with options" do
|
125
130
|
expect(subject.verify 'equals?', ['resource1', 'resource2']).
|
126
|
-
to eq(
|
131
|
+
to eq({ resources: [{ id: "resource1", status: 2 },
|
132
|
+
{ id: "resource2", status: 2 }], passing: true })
|
127
133
|
end
|
128
134
|
|
129
135
|
it "should verify the given verification against each resource in the collection" do
|
130
136
|
[resource1, resource2].each {|r| r.define_singleton_method :valid_resource?, lambda { true } }
|
131
137
|
expect(subject.verify 'valid_resource?').
|
132
|
-
to eq(
|
138
|
+
to eq({ resources: [{ id: "resource1", status: 0 },
|
139
|
+
{ id: "resource2", status: 0 }], passing: true })
|
133
140
|
end
|
134
141
|
|
135
142
|
it "should appaned a ? to the policy" do
|
136
143
|
expect(subject.verify 'none_exist').
|
137
|
-
to eq( {
|
144
|
+
to eq({ resources: [{ id: "resource1", status: 2 },
|
145
|
+
{ id: "resource2", status: 2 }], passing: false })
|
138
146
|
end
|
139
147
|
|
140
148
|
it "should remove all but the target resources if one is required and given" do
|
@@ -142,7 +150,7 @@ describe Outliers::Collection do
|
|
142
150
|
resource1.should_receive(:method).with('valid_resource?').and_return(stub 'method', :arity => 0)
|
143
151
|
resource1.should_receive(:valid_resource?).and_return false
|
144
152
|
expect(subject.verify 'valid_resource?').
|
145
|
-
to eq( {
|
153
|
+
to eq({ resources: [{ id: "resource1", status: 1 }], passing: false })
|
146
154
|
end
|
147
155
|
|
148
156
|
it "should raise an error if the target resources does not exist" do
|
@@ -161,16 +169,18 @@ describe Outliers::Collection do
|
|
161
169
|
to raise_error(Outliers::Exceptions::NoArgumentRequired)
|
162
170
|
end
|
163
171
|
|
164
|
-
it "should return empty
|
172
|
+
it "should return empty resource array if no resources exist in list" do
|
165
173
|
subject.stub :load_all => []
|
166
|
-
expect(subject.verify 'valid_resource?', {}).
|
174
|
+
expect(subject.verify 'valid_resource?', {}).
|
175
|
+
to eq( { resources: [], passing: true } )
|
167
176
|
end
|
168
177
|
|
169
178
|
it "should verify the given verification against each resource in the collection with options" do
|
170
179
|
resource1.should_receive(:valid_resource?).with('test_arg' => 2).and_return true
|
171
180
|
resource2.should_receive(:valid_resource?).with('test_arg' => 2).and_return true
|
172
181
|
expect(subject.verify 'valid_resource?', 'test_arg' => 2).
|
173
|
-
to eq( {
|
182
|
+
to eq( { resources: [ { id: "resource1", status: 0},
|
183
|
+
{ id: "resource2", status: 0}], passing: true} )
|
174
184
|
end
|
175
185
|
end
|
176
186
|
|
data/spec/evaluation_spec.rb
CHANGED
@@ -124,7 +124,7 @@ describe Outliers::Evaluation do
|
|
124
124
|
context "#verify" do
|
125
125
|
let(:result1) { stub 'result1', :passed? => true }
|
126
126
|
let(:result2) { stub 'result2', :passed? => true }
|
127
|
-
let(:verification_response) { ( {
|
127
|
+
let(:verification_response) { ( { resources: [{ id: '3', status: 0}, { id: '4', status: 0}], passing: true } ) }
|
128
128
|
|
129
129
|
before do
|
130
130
|
resources.should_receive(:load_all).and_return ['resource1', 'resource2']
|
@@ -135,9 +135,9 @@ describe Outliers::Evaluation do
|
|
135
135
|
resources.should_receive(:verify).with('test_verification?', nil).and_return verification_response
|
136
136
|
Outliers::Result.should_receive(:new).with(account_name: 'test_account_1',
|
137
137
|
arguments: [],
|
138
|
-
|
138
|
+
resources: [{ id: '3', status: 0}, { id: '4', status: 0}],
|
139
139
|
name: 'test',
|
140
|
-
|
140
|
+
passing: true,
|
141
141
|
provider_name: 'aws_ec2',
|
142
142
|
resource_name: 'security_group',
|
143
143
|
verification_name: 'test_verification?').and_return result1
|
@@ -148,9 +148,9 @@ describe Outliers::Evaluation do
|
|
148
148
|
resources.should_receive(:verify).with('test_verification?', ['test123']).and_return verification_response
|
149
149
|
Outliers::Result.should_receive(:new).with(account_name: 'test_account_1',
|
150
150
|
arguments: ['test123'],
|
151
|
-
|
151
|
+
resources: [{ id: '3', status: 0}, { id: '4', status: 0}],
|
152
152
|
name: 'test',
|
153
|
-
|
153
|
+
passing: true,
|
154
154
|
provider_name: 'aws_ec2',
|
155
155
|
resource_name: 'security_group',
|
156
156
|
verification_name: 'test_verification?').and_return result1
|
@@ -161,9 +161,9 @@ describe Outliers::Evaluation do
|
|
161
161
|
resources.should_receive(:verify).with('test_verification?', ['arg']).and_return verification_response
|
162
162
|
Outliers::Result.should_receive(:new).with(account_name: 'test_account_1',
|
163
163
|
arguments: ['arg'],
|
164
|
-
|
164
|
+
resources: [{ id: '3', status: 0}, { id: '4', status: 0}],
|
165
165
|
name: 'test',
|
166
|
-
|
166
|
+
passing: true,
|
167
167
|
provider_name: 'aws_ec2',
|
168
168
|
resource_name: 'security_group',
|
169
169
|
verification_name: 'test_verification?').and_return result1
|
@@ -180,17 +180,17 @@ describe Outliers::Evaluation do
|
|
180
180
|
resources.should_receive(:verify).with('test_verification2?', ['arg2']).and_return verification_response
|
181
181
|
Outliers::Result.should_receive(:new).with(account_name: 'test_account_1',
|
182
182
|
arguments: ['arg1'],
|
183
|
-
|
183
|
+
resources: [{ id: '3', status: 0}, { id: '4', status: 0}],
|
184
184
|
name: 'test',
|
185
|
-
|
185
|
+
passing: true,
|
186
186
|
provider_name: 'aws_ec2',
|
187
187
|
resource_name: 'security_group',
|
188
188
|
verification_name: 'test_verification1?').and_return result1
|
189
189
|
Outliers::Result.should_receive(:new).with(account_name: 'test_account_1',
|
190
190
|
arguments: ['arg2'],
|
191
|
-
|
191
|
+
resources: [{ id: '3', status: 0}, { id: '4', status: 0}],
|
192
192
|
name: 'test',
|
193
|
-
|
193
|
+
passing: true,
|
194
194
|
provider_name: 'aws_ec2',
|
195
195
|
resource_name: 'security_group',
|
196
196
|
verification_name: 'test_verification2?').and_return result2
|
data/spec/info_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe Outliers::Info do
|
|
42
42
|
|
43
43
|
context "#shared" do
|
44
44
|
before do
|
45
|
-
@verifications = Outliers::Verifications::Shared.instance_methods.map {|m| m.to_s.chomp('?')}
|
45
|
+
@verifications = Outliers::Verifications::Shared::Collection.instance_methods.map {|m| m.to_s.chomp('?')}
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should be able to load shared.yaml" do
|
data/spec/results_spec.rb
CHANGED
@@ -7,9 +7,10 @@ describe Outliers::Result do
|
|
7
7
|
context "passing" do
|
8
8
|
subject { Outliers::Result.new account_name: 'cnt',
|
9
9
|
arguments: ['test123'],
|
10
|
-
failing_resources: [],
|
11
10
|
name: 'evalme',
|
12
|
-
|
11
|
+
resources: [{ id: 'resource1', status: 0 },
|
12
|
+
{ id: 'resource1', status: 0 }],
|
13
|
+
passing: true,
|
13
14
|
provider_name: 'aws',
|
14
15
|
resource_name: 'instance',
|
15
16
|
verification_name: 'vpc' }
|
@@ -22,16 +23,14 @@ describe Outliers::Result do
|
|
22
23
|
expect(subject.failed?).to be_false
|
23
24
|
end
|
24
25
|
|
25
|
-
it "should return the result information" do
|
26
|
-
expect(subject.passing_resources).to eq([resource1, resource2])
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
26
|
it "should return the result information" do
|
31
27
|
expect(subject.account_name).to eq('cnt')
|
32
|
-
expect(subject.
|
28
|
+
expect(subject.resources).to eq([{ id: 'resource1', status: 0 },
|
29
|
+
{ id: 'resource1', status: 0 }])
|
33
30
|
expect(subject.name).to eq('evalme')
|
34
|
-
expect(subject.
|
31
|
+
expect(subject.passing).to eq(true)
|
32
|
+
expect(subject.passed?).to eq(true)
|
33
|
+
expect(subject.failed?).to eq(false)
|
35
34
|
expect(subject.provider_name).to eq('aws')
|
36
35
|
expect(subject.resource_name).to eq('instance')
|
37
36
|
expect(subject.verification_name).to eq('vpc')
|
@@ -47,28 +46,30 @@ describe Outliers::Result do
|
|
47
46
|
|
48
47
|
context "#to_json" do
|
49
48
|
it "should return the results as json" do
|
50
|
-
resources = [ { 'id' => 1, 'passing' => 1 }, { 'id' => 2, 'passing' => 1 } ]
|
51
49
|
json = { 'account_name' => 'cnt',
|
52
50
|
'arguments' => ['test123'],
|
53
51
|
'name' => 'evalme',
|
52
|
+
'passing' => true,
|
54
53
|
'provider_name' => 'aws',
|
55
54
|
'resource_name' => 'instance',
|
56
55
|
'verification_name' => 'vpc',
|
57
|
-
'resources' =>
|
56
|
+
'resources' => [{ id: 'resource1', status: 0 },
|
57
|
+
{ id: 'resource1', status: 0 }] }.to_json
|
58
58
|
expect(subject.to_json).to eq(json)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context "#to_hash" do
|
63
63
|
it "should return the results as hash" do
|
64
|
-
resources = [ { 'id' => 1, 'passing' => 1 }, { 'id' => 2, 'passing' => 1 } ]
|
65
64
|
hash = { 'account_name' => 'cnt',
|
66
65
|
'arguments' => ['test123'],
|
67
66
|
'name' => 'evalme',
|
67
|
+
'passing' => true,
|
68
68
|
'provider_name' => 'aws',
|
69
69
|
'resource_name' => 'instance',
|
70
70
|
'verification_name' => 'vpc',
|
71
|
-
'resources' =>
|
71
|
+
'resources' => [{ id: 'resource1', status: 0 },
|
72
|
+
{ id: 'resource1', status: 0 }] }.to_hash
|
72
73
|
expect(subject.to_hash).to eq(hash)
|
73
74
|
end
|
74
75
|
end
|
data/spec/run_spec.rb
CHANGED
@@ -93,26 +93,4 @@ describe Outliers::Run do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
context "returning results" do
|
97
|
-
let(:result1) { Outliers::Result.new name: 'result1', passing_resources: [], failing_resources: [], verification_name: 'ver' }
|
98
|
-
let(:result2) { Outliers::Result.new name: 'result2', passing_resources: [], failing_resources: ['failed'], verification_name: 'ver' }
|
99
|
-
|
100
|
-
before do
|
101
|
-
subject.results << result1
|
102
|
-
subject.results << result2
|
103
|
-
end
|
104
|
-
|
105
|
-
describe "#passed" do
|
106
|
-
it "should return an array of all passing results" do
|
107
|
-
expect(subject.passing_results).to eq([result1])
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#failed" do
|
112
|
-
it "should return an array of all failing results" do
|
113
|
-
expect(subject.failing_results).to eq([result2])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
96
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Outliers::Verifications::Shared do
|
4
|
-
subject { Object.new.extend Outliers::Verifications::Shared }
|
3
|
+
describe Outliers::Verifications::Shared::Collection do
|
4
|
+
subject { Object.new.extend Outliers::Verifications::Shared::Collection }
|
5
5
|
let(:resource1) { stub "resource1", id: 'resource1' }
|
6
6
|
let(:resource2) { stub "resource2", id: 'resource2' }
|
7
7
|
|
@@ -13,30 +13,35 @@ describe Outliers::Verifications::Shared do
|
|
13
13
|
context "#none_exist?" do
|
14
14
|
it "should be true if no resources returned" do
|
15
15
|
subject.stub :list => []
|
16
|
-
expect(subject.none_exist?).
|
16
|
+
expect(subject.none_exist?).
|
17
|
+
to eq({ resources: [], passing: true })
|
17
18
|
end
|
18
19
|
|
19
|
-
it "should be false if
|
20
|
-
subject.stub :list_by_key => ['resource1']
|
21
|
-
subject.
|
22
|
-
|
20
|
+
it "should be false if resource returned" do
|
21
|
+
subject.stub :list_by_key => ['resource1'], :list => [resource1]
|
22
|
+
expect(subject.none_exist?).
|
23
|
+
to eq({ resources: [{ id: 'resource1', status:2 }], passing: false })
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
context "#equals?" do
|
27
|
-
it "should
|
28
|
+
it "should return passing true if the list matches" do
|
28
29
|
subject.stub :list_by_key => ['resource1'], :list => [resource1]
|
29
|
-
expect(subject.equals?(
|
30
|
+
expect(subject.equals?('resource1')).
|
31
|
+
to eq({ resources: [{ id: 'resource1', status:2 }], passing: true })
|
30
32
|
end
|
31
33
|
|
32
|
-
it "should
|
33
|
-
subject.stub :list_by_key => ['resource1'], :list => [resource1]
|
34
|
-
expect(subject.equals?('resource1')).
|
34
|
+
it "should return passing false if the resources do match the given list" do
|
35
|
+
subject.stub :list_by_key => ['resource1', 'resource2'], :list => [resource1, resource2]
|
36
|
+
expect(subject.equals?('resource1')).
|
37
|
+
to eq({ resources: [{ id: 'resource1', status:2 },
|
38
|
+
{ id: 'resource2', status:2 }], passing: false })
|
35
39
|
end
|
36
40
|
|
37
|
-
it "should return
|
38
|
-
subject.stub :list_by_key => [
|
39
|
-
expect(subject.equals?('resource1')).
|
41
|
+
it "should return passing false if the list is empty" do
|
42
|
+
subject.stub :list_by_key => [], :list => []
|
43
|
+
expect(subject.equals?('resource1')).
|
44
|
+
to eq({ resources: [], passing: false })
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outliers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Weaver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -137,7 +137,8 @@ files:
|
|
137
137
|
- lib/outliers/result.rb
|
138
138
|
- lib/outliers/run.rb
|
139
139
|
- lib/outliers/verifications.rb
|
140
|
-
- lib/outliers/verifications/shared.rb
|
140
|
+
- lib/outliers/verifications/collection/shared.rb
|
141
|
+
- lib/outliers/verifications/shared/collection.rb
|
141
142
|
- lib/outliers/version.rb
|
142
143
|
- outliers.gemspec
|
143
144
|
- reference.yaml
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Outliers
|
2
|
-
module Verifications
|
3
|
-
module Shared
|
4
|
-
|
5
|
-
def none_exist?
|
6
|
-
list
|
7
|
-
end
|
8
|
-
|
9
|
-
def equals?(args)
|
10
|
-
keys = Array(args)
|
11
|
-
logger.debug "Verifying '#{keys.join(',')}' equals '#{list.empty? ? 'no resources' : list_by_key.join(',')}'."
|
12
|
-
list.reject {|r| keys.include? r.id}
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|