outliers 0.0.0 → 0.0.1

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 (78) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +3 -0
  6. data/LICENSE.txt +10 -19
  7. data/README.md +175 -8
  8. data/Rakefile +7 -0
  9. data/bin/outliers +6 -0
  10. data/lib/outliers/cli/evaluate.rb +115 -0
  11. data/lib/outliers/cli/process.rb +56 -0
  12. data/lib/outliers/cli/providers.rb +29 -0
  13. data/lib/outliers/cli/resources.rb +57 -0
  14. data/lib/outliers/cli.rb +78 -0
  15. data/lib/outliers/collection.rb +124 -0
  16. data/lib/outliers/credentials.rb +28 -0
  17. data/lib/outliers/evaluation.rb +85 -0
  18. data/lib/outliers/exceptions.rb +40 -0
  19. data/lib/outliers/mixins.rb +27 -0
  20. data/lib/outliers/provider.rb +32 -0
  21. data/lib/outliers/providers/aws/base.rb +33 -0
  22. data/lib/outliers/providers/aws/cloud_formation.rb +20 -0
  23. data/lib/outliers/providers/aws/ec2.rb +20 -0
  24. data/lib/outliers/providers/aws/elb.rb +20 -0
  25. data/lib/outliers/providers/aws/iam.rb +20 -0
  26. data/lib/outliers/providers/aws/rds.rb +20 -0
  27. data/lib/outliers/providers/aws/s3.rb +20 -0
  28. data/lib/outliers/providers/aws/sqs.rb +20 -0
  29. data/lib/outliers/providers/aws.rb +9 -0
  30. data/lib/outliers/providers/github.rb +23 -0
  31. data/lib/outliers/providers.rb +19 -0
  32. data/lib/outliers/resource.rb +34 -0
  33. data/lib/outliers/resources/aws/cloud_formation/stack.rb +10 -0
  34. data/lib/outliers/resources/aws/cloud_formation/stack_collection.rb +15 -0
  35. data/lib/outliers/resources/aws/ec2/instance.rb +75 -0
  36. data/lib/outliers/resources/aws/ec2/instance_collection.rb +15 -0
  37. data/lib/outliers/resources/aws/ec2/security_group.rb +28 -0
  38. data/lib/outliers/resources/aws/ec2/security_group_collection.rb +15 -0
  39. data/lib/outliers/resources/aws/elb/load_balancer.rb +51 -0
  40. data/lib/outliers/resources/aws/elb/load_balancer_collection.rb +15 -0
  41. data/lib/outliers/resources/aws/iam/user.rb +40 -0
  42. data/lib/outliers/resources/aws/iam/user_collection.rb +15 -0
  43. data/lib/outliers/resources/aws/rds/db_instance.rb +35 -0
  44. data/lib/outliers/resources/aws/rds/db_instance_collection.rb +15 -0
  45. data/lib/outliers/resources/aws/rds/db_snapshot.rb +13 -0
  46. data/lib/outliers/resources/aws/rds/db_snapshot_collection.rb +15 -0
  47. data/lib/outliers/resources/aws/s3/bucket.rb +73 -0
  48. data/lib/outliers/resources/aws/s3/bucket_collection.rb +18 -0
  49. data/lib/outliers/resources/aws/sqs/queue.rb +13 -0
  50. data/lib/outliers/resources/aws/sqs/queue_collection.rb +15 -0
  51. data/lib/outliers/resources/aws.rb +18 -0
  52. data/lib/outliers/resources/github/repo.rb +24 -0
  53. data/lib/outliers/resources/github/repo_collection.rb +13 -0
  54. data/lib/outliers/resources/github.rb +2 -0
  55. data/lib/outliers/resources.rb +12 -0
  56. data/lib/outliers/result.rb +24 -0
  57. data/lib/outliers/run.rb +40 -0
  58. data/lib/outliers/verifications/shared.rb +31 -0
  59. data/lib/outliers/verifications.rb +1 -0
  60. data/lib/outliers/version.rb +1 -1
  61. data/lib/outliers.rb +24 -1
  62. data/outliers.gemspec +9 -5
  63. data/spec/collection_spec.rb +103 -0
  64. data/spec/credentials_spec.rb +42 -0
  65. data/spec/evaluation_spec.rb +96 -0
  66. data/spec/fixtures/credentials1.yml +5 -0
  67. data/spec/fixtures/credentials2.yml +5 -0
  68. data/spec/helpers/fixtures.rb +8 -0
  69. data/spec/mixins_spec.rb +33 -0
  70. data/spec/provider_spec.rb +35 -0
  71. data/spec/providers_spec.rb +18 -0
  72. data/spec/resource_spec.rb +19 -0
  73. data/spec/resources_spec.rb +15 -0
  74. data/spec/results_spec.rb +33 -0
  75. data/spec/run_spec.rb +56 -0
  76. data/spec/spec_helper.rb +21 -0
  77. data/spec/verifications/shared_spec.rb +35 -0
  78. metadata +145 -29
data/outliers.gemspec CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Outliers::VERSION
9
9
  spec.authors = ["Brett Weaver"]
10
10
  spec.email = ["brett@weav.net"]
11
- spec.description = %q{To Be Announced.}
12
- spec.summary = %q{To Be Announced.}
13
- spec.homepage = ""
14
- spec.license = "MIT"
11
+ spec.description = %q{Configuraiton verification framework.}
12
+ spec.summary = %q{Configuration verification framework.}
13
+ spec.homepage = "https://github.com/brettweavnet/outliers"
14
+ spec.license = "Apache2"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -19,5 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rake", "~> 10.1.0"
23
+ spec.add_development_dependency "rspec", "~> 2.13.0"
24
+
25
+ spec.add_runtime_dependency "aws-sdk", "1.14.1"
26
+ spec.add_runtime_dependency "github_api", "0.10.1"
23
27
  end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Collection do
4
+ let(:provider) { mock 'provider' }
5
+ let(:resource1) { mock 'resource1' }
6
+ let(:resource2) { mock 'resource2' }
7
+ let(:resource_class) { stub 'resource_class', key: 'name',
8
+ verifications_requiring_target: ['target_me?'] }
9
+
10
+ subject { Outliers::Collection.new provider }
11
+
12
+ before do
13
+ stub_logger
14
+ resource1.stub name: 'resource1', key: 'name', id: 'resource1'
15
+ resource2.stub name: 'resource2', key: 'name', id: 'resource2'
16
+ subject.stub :load_all => [resource1, resource2],
17
+ :class => Outliers::Resources::Aws::Ec2::SecurityGroupCollection
18
+ end
19
+
20
+ context "#to_human" do
21
+ it "should return the human name for this resource" do
22
+ expect(Outliers::Resources::Aws::Ec2::SecurityGroupCollection.to_human).to eq('aws_ec2_security_group')
23
+ expect(Outliers::Resources::Github::RepoCollection.to_human).to eq('github_repo')
24
+ end
25
+ end
26
+
27
+ context "#each" do
28
+ it "should iterate over all resources when block given" do
29
+ expect(subject.each {|r| r}).to eq([resource1, resource2])
30
+ end
31
+ end
32
+
33
+ context "#exclude" do
34
+ it "should exclude the given array of resources" do
35
+ subject.exclude_by_key ['resource1']
36
+ expect(subject.all).to eq([resource2])
37
+ end
38
+ end
39
+
40
+ context "#key" do
41
+ it "should return the key for the resource" do
42
+ expect(subject.key).to eq('name')
43
+ end
44
+ end
45
+
46
+ context "#resource_class" do
47
+ it "should return the resource_class for the resource" do
48
+ expect(subject.resource_class).to eq(Outliers::Resources::Aws::Ec2::SecurityGroup)
49
+ end
50
+ end
51
+
52
+ context "#verify" do
53
+ before do
54
+ Outliers::Collection.stub :resource_class => resource_class
55
+ end
56
+
57
+ it "should verify the given verification against the colection" do
58
+ expect(subject.verify 'none?', {}).to be_false
59
+ end
60
+
61
+ it "should verify the given verification against the colection with options" do
62
+ expect(subject.verify 'equals?', :keys => ['resource1', 'resource2']).to be_true
63
+ end
64
+
65
+ it "should verify the given verification against each resource in the collection" do
66
+ [resource1, resource2].each {|r| r.define_singleton_method :valid_resource?, lambda { true } }
67
+ expect(subject.verify 'valid_resource?').to be_true
68
+ end
69
+
70
+ it "should appaned a ? to the policy" do
71
+ expect(subject.verify 'none').to be_false
72
+ end
73
+
74
+ it "should remove all but the target resources if one is required and given" do
75
+ subject.targets = ['resource1', 'in-valid']
76
+ resource1.should_receive(:method).with('target_me?').and_return(stub 'method', :arity => 0)
77
+ resource1.should_receive(:target_me?)
78
+ expect(subject.verify 'target_me?').to be_true
79
+ end
80
+
81
+ it "should raise an error if the target resources does not exist" do
82
+ subject.targets = ['in-valid']
83
+ expect { subject.verify 'target_me?' }.to raise_error(Outliers::Exceptions::TargetNotFound)
84
+ end
85
+
86
+ it "should raise an error if the verification requires arguments and none given" do
87
+ resource1.define_singleton_method :valid_resource?, lambda { |required_args| true }
88
+ expect { subject.verify 'valid_resource?' }.to raise_error(Outliers::Exceptions::ArgumentRequired)
89
+ end
90
+
91
+ it "should raise an error if the verification does not require arguments and arguments are given" do
92
+ resource1.define_singleton_method :valid_resource?, lambda { true }
93
+ expect { subject.verify 'valid_resource?', 'unneeded argument' => 3 }.to raise_error(Outliers::Exceptions::NoArgumentRequired)
94
+ end
95
+
96
+ it "should verify the given verification against each resource in the collection with options" do
97
+ resource1.should_receive(:valid_resource?).with('test_arg' => 2).and_return true
98
+ resource2.should_receive(:valid_resource?).with('test_arg' => 2).and_return true
99
+ expect(subject.verify 'valid_resource?', 'test_arg' => 2).to be_true
100
+ end
101
+ end
102
+
103
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Credentials do
4
+ subject { Outliers::Credentials }
5
+ let(:credentials1) { fixture_file 'credentials1.yml' }
6
+ let(:credentials2) { fixture_file 'credentials2.yml' }
7
+ context "#load_from_config_folder" do
8
+ before { Outliers.config_path '/test' }
9
+ it "should load the credentials from each file in the directory" do
10
+ Dir.should_receive(:entries).with('/test/credentials').
11
+ and_return ['.', '..', 'test1.yml', 'test2.yml']
12
+ File.should_receive(:read).with('/test/credentials/test1.yml').and_return credentials1
13
+ File.should_receive(:read).with('/test/credentials/test2.yml').and_return credentials2
14
+ results = { "test_credentials_1" =>
15
+ { "region" => "us-west-1",
16
+ "provider" => "aws_ec2",
17
+ "access_key_id" => "01234567890123456789",
18
+ "secret_access_key" =>"0123456789012345678901234567890123456789" },
19
+ "test_credentials_2" =>
20
+ { "region" => "us-west-1",
21
+ "provider" => "aws_ec2",
22
+ "access_key_id" => "01234567890123456789",
23
+ "secret_access_key" => "0123456789012345678901234567890123456789" }
24
+ }
25
+ expect(subject.load_from_config_folder).to eq(results)
26
+ end
27
+ end
28
+
29
+ context "#load_from_file" do
30
+ it "should load the credentials from the given yaml file" do
31
+ File.should_receive(:read).with('/home/user/outliers.yml').and_return credentials1
32
+ results = { "test_credentials_1" =>
33
+ { "region" => "us-west-1",
34
+ "provider" => "aws_ec2",
35
+ "access_key_id" => "01234567890123456789",
36
+ "secret_access_key" =>"0123456789012345678901234567890123456789" }
37
+ }
38
+ expect(subject.load_from_file '/home/user/outliers.yml').to eq(results)
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Evaluation do
4
+ let(:run) { mock 'run' }
5
+ let(:result) { mock 'result' }
6
+ let(:connect) { subject.connect('test_credentials_1') }
7
+ let(:resources) { subject.resources('security_group') }
8
+ subject { Outliers::Evaluation.new :run => run, :name => 'test' }
9
+
10
+ before do
11
+ stub_logger
12
+ run.stub :credentials => credentials
13
+ end
14
+
15
+ context "#connect" do
16
+ it "should connect to the provider" do
17
+ connect
18
+ expect(subject.provider_name_array).to eq(['Aws', 'Ec2'])
19
+ end
20
+
21
+ it "should connect to the provider specified as an option" do
22
+ subject.connect('test_credentials_1', { 'provider' => 'aws_rds' })
23
+ expect(subject.provider_name_array).to eq(['Aws', 'Rds'])
24
+ end
25
+
26
+ it "should throw an error if the provider if the provider class is unkown" do
27
+ expect { subject.connect('test_credentials_1', { 'provider' => 'bad_provider' }) }.
28
+ to raise_error(Outliers::Exceptions::UnknownProvider)
29
+ end
30
+
31
+ it "should override a valid provider with one provided" do
32
+ subject.connect('test_credentials_1', { 'provider' => 'aws_ec2' })
33
+ expect(subject.provider_name_array).to eq(['Aws', 'Ec2'])
34
+ end
35
+ end
36
+
37
+ context "with connection and resources" do
38
+ before do
39
+ connect
40
+ resources
41
+ end
42
+
43
+ context "#resources" do
44
+ it "should assign the collection_object" do
45
+ expect(subject.collection.class).
46
+ to eq(Outliers::Resources::Aws::Ec2::SecurityGroupCollection)
47
+ expect(subject.collection.provider.class).
48
+ to eq(Outliers::Providers::Aws::Ec2)
49
+ end
50
+
51
+ it "should throw an error when given an invalid collection" do
52
+ expect { subject.resources('bad_collection') }.
53
+ to raise_error(Outliers::Exceptions::UnknownCollection)
54
+ end
55
+
56
+ it "should test that over ride options are applied when selecting colleciton" do
57
+ subject.connect('test_credentials_1', :provider => 'aws_rds')
58
+ subject.resources('db_instance')
59
+ expect(subject.collection.provider.class).
60
+ to eq(Outliers::Providers::Aws::Rds)
61
+ end
62
+
63
+ it "should set the collection targets if specified" do
64
+ subject.connect('test_credentials_1', :provider => 'aws_rds')
65
+ expect(subject.resources('db_instance', 'instance-123').targets).to eq ['instance-123']
66
+ end
67
+ end
68
+
69
+ context "#exclude" do
70
+ it "should convert input to array and send call exclude_by_key with value" do
71
+ resources.should_receive(:exclude_by_key).with(['test'])
72
+ subject.exclude 'test'
73
+ end
74
+ end
75
+
76
+ context "#verify" do
77
+ before do
78
+ resources.should_receive(:load_all)
79
+ Outliers::Result.should_receive(:new).with(description: 'test', :passed => true).and_return result
80
+ run.should_receive(:results).and_return([])
81
+ end
82
+
83
+ it "should verify the given method" do
84
+ resources.should_receive(:verify).with('test_verification?', {}).and_return(true)
85
+ expect(subject.verify('test_verification?', {})).to eq([result])
86
+ end
87
+
88
+ it "should convert all options to symbols" do
89
+ resources.should_receive(:verify).with('test_verification?', :test => false).and_return(true)
90
+ expect(subject.verify('test_verification?', { 'test' => false } )).to eq([result])
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+ end
@@ -0,0 +1,5 @@
1
+ test_credentials_1:
2
+ region: us-west-1
3
+ provider: aws_ec2
4
+ access_key_id: 01234567890123456789
5
+ secret_access_key: 0123456789012345678901234567890123456789
@@ -0,0 +1,5 @@
1
+ test_credentials_2:
2
+ region: us-west-1
3
+ provider: aws_ec2
4
+ access_key_id: 01234567890123456789
5
+ secret_access_key: 0123456789012345678901234567890123456789
@@ -0,0 +1,8 @@
1
+ module Fixtures
2
+
3
+ def fixture_file(file)
4
+ path = File.expand_path(File.join(__FILE__, '..', '..', 'fixtures', file))
5
+ IO.read path
6
+ end
7
+
8
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module TestModule
4
+ module TestSubModule
5
+ class TestClass
6
+ end
7
+ end
8
+ end
9
+
10
+ describe do
11
+ context "#all_the_modules" do
12
+ it "should return all the modules and classes for a object recursivley" do
13
+ expect(TestModule.all_the_modules).
14
+ to eq([TestModule, TestModule::TestSubModule, TestModule::TestSubModule::TestClass])
15
+ end
16
+ end
17
+ context "#keys_to_sym" do
18
+ it "should convert all hash keys to symbols" do
19
+ expect({ 'key' => 'val' }.keys_to_sym).to eq({ key: 'val' })
20
+ end
21
+ end
22
+ context "#keys_to_string" do
23
+ it "should convert all hash keys to string" do
24
+ expect({ key: 'val' }.keys_to_s).to eq({ 'key' => 'val' })
25
+ end
26
+ end
27
+ context "#underscore" do
28
+ it "should convert camel case to snack case" do
29
+ expect('TestCamelCase123'.underscore).to eq('test_camel_case123')
30
+ expect('Test123CamelCase'.underscore).to eq('test123_camel_case')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Provider do
4
+ subject { Outliers::Provider }
5
+
6
+ context "#connect_to" do
7
+ let(:credentials) { ( { :name => "test_credentials_1",
8
+ "provider" => "github",
9
+ "token" => "abc" } ) }
10
+
11
+ it "should connect to the provider specified in the given credentials" do
12
+ expect(subject.connect_to(credentials).class).to eq(Outliers::Providers::Github)
13
+ end
14
+
15
+ it "should set the credentials instance variable" do
16
+ expect(subject.connect_to(credentials).credentials).
17
+ to eq({ :name => "test_credentials_1", "provider" => "github", "token" => "abc" })
18
+ end
19
+ end
20
+
21
+ context "#to_human" do
22
+ it "should return the name a human would use to access the provider" do
23
+ expect(Outliers::Providers::Github.to_human).to eq('github')
24
+ end
25
+
26
+ it "should return the name a human would use to access the provider" do
27
+ expect(Outliers::Providers::Aws::Rds.to_human).to eq('aws_rds')
28
+ end
29
+
30
+ it "should return the name a human would use to access the provider" do
31
+ expect(Outliers::Providers::Aws::CloudFormation.to_human).to eq('aws_cloud_formation')
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Providers do
4
+ subject { Outliers::Providers }
5
+ before do
6
+ subject.stub :all_the_modules => [Outliers::Providers::Aws, Outliers::Providers::Aws::Ec2]
7
+ end
8
+
9
+ it "should return all the providers" do
10
+ expect(subject.all).to eq([Outliers::Providers::Aws::Ec2])
11
+ end
12
+
13
+ context "#name_map" do
14
+ it "should return a map of resource human names to objects" do
15
+ expect(subject.name_map).to eq({ 'aws_ec2' => Outliers::Providers::Aws::Ec2 })
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Resource do
4
+ let(:provider) { mock 'provider' }
5
+ subject { Outliers::Resource.new provider }
6
+
7
+ context "#method_missing" do
8
+ it "should send missing methods to the source object" do
9
+ provider.stub :test_method => true
10
+ expect(subject.send 'test_method').to be_true
11
+ end
12
+ end
13
+
14
+ context "#self.key" do
15
+ it "should valid key returns name" do
16
+ expect(Outliers::Resource.key).to eq('name')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Resources do
4
+ subject { Outliers::Resources }
5
+
6
+ context "#collections" do
7
+ it "should return all the collections" do
8
+ Outliers::Resources.stub :all_the_modules => [Outliers::Resources::Aws::Ec2,
9
+ Outliers::Resources::Aws::Ec2::SecurityGroup,
10
+ Outliers::Resources::Aws::Ec2::SecurityGroupCollection]
11
+ expect(subject.collections).to eq([Outliers::Resources::Aws::Ec2::SecurityGroupCollection])
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Result do
4
+ context "passing" do
5
+ subject { Outliers::Result.new description: 'stuff', passed: true }
6
+ it "should return passed" do
7
+ expect(subject.to_s).to eq 'passed'
8
+ end
9
+
10
+ it "should return true for passing verification" do
11
+ expect(subject.passed?).to be_true
12
+ end
13
+
14
+ it "should return false for passing verification" do
15
+ expect(subject.failed?).to be_false
16
+ end
17
+ end
18
+
19
+ context "failing" do
20
+ subject { Outliers::Result.new description: 'stuff', passed: false }
21
+ it "should return passed" do
22
+ expect(subject.to_s).to eq 'failed'
23
+ end
24
+
25
+ it "should return false for failing verification" do
26
+ expect(subject.passed?).to be_false
27
+ end
28
+
29
+ it "should return true for failing verification" do
30
+ expect(subject.failed?).to be_true
31
+ end
32
+ end
33
+ end
data/spec/run_spec.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Run do
4
+ let(:evaluation1) { mock "evaluation1" }
5
+ let(:evaluation2) { mock "evaluation2" }
6
+
7
+ before do
8
+ stub_logger
9
+ end
10
+
11
+ describe "#process_evaluations_in_config_folder" do
12
+ it "should process all evaluation files in config folder" do
13
+ Dir.should_receive(:entries).with('/test').and_return ['.', '..', 'test1.rb', 'test2.rb']
14
+ File.should_receive(:read).with('/test/test1.rb').and_return evaluation1
15
+ File.should_receive(:read).with('/test/test2.rb').and_return evaluation2
16
+
17
+ subject.should_receive(:instance_eval).with(evaluation1)
18
+ subject.should_receive(:instance_eval).with(evaluation2)
19
+ subject.process_evaluations_in_config_folder
20
+ end
21
+
22
+ it "should skip directories"
23
+ it "should only evaluate .rb files"
24
+ end
25
+
26
+ describe "#evaluate" do
27
+ it "should kick off a new evaluation and yield it to the block" do
28
+ Outliers::Evaluation.should_receive(:new).with(:name => 'my evaluation', :run => subject).and_return evaluation1
29
+ subject.evaluate('my evaluation') do |e|
30
+ expect(e).to eq(evaluation1)
31
+ end
32
+ end
33
+ end
34
+
35
+ context "returning results" do
36
+ let(:result1) { Outliers::Result.new description: 'result1', passed: true }
37
+ let(:result2) { Outliers::Result.new description: 'result2', passed: false }
38
+ before do
39
+ subject.results << result1
40
+ subject.results << result2
41
+ end
42
+
43
+ describe "#passed" do
44
+ it "should return an array of all passing results" do
45
+ expect(subject.passed).to eq([result1])
46
+ end
47
+ end
48
+
49
+ describe "#failed" do
50
+ it "should return an array of all failing results" do
51
+ expect(subject.failed).to eq([result2])
52
+ end
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'outliers'
5
+
6
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'helpers', '*.rb'))].each do |f|
7
+ require f
8
+ end
9
+
10
+ def credentials
11
+ YAML.load(fixture_file 'credentials1.yml')
12
+ end
13
+
14
+ def stub_logger
15
+ Outliers.logger stub 'test'
16
+ Outliers.logger.stub :debug => true, :info => true, :warn => true
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ config.include Fixtures
21
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Outliers::Verifications::Shared do
4
+ subject { Object.new.extend Outliers::Verifications::Shared }
5
+
6
+ before do
7
+ logger_stub = stub 'logger', :debug => true
8
+ subject.stub :logger => logger_stub
9
+ end
10
+
11
+ context "#none_exist?" do
12
+ it "should be true if no resources returned" do
13
+ subject.stub :all => []
14
+ expect(subject.none_exist?).to be_true
15
+ end
16
+
17
+ it "should be false if resources returned" do
18
+ subject.stub :all_by_key => ['test']
19
+ subject.stub :all => ['test']
20
+ expect(subject.none_exist?).to be_false
21
+ end
22
+ end
23
+
24
+ context "#equals?" do
25
+ it "should verify the list of resources equals the list of keys" do
26
+ subject.stub :all_by_key => ['test'], :all => ['test_resource']
27
+ expect(subject.equals?(:keys => ['test'])).to be_true
28
+ end
29
+
30
+ it "should verify the list of resources equals the single key" do
31
+ subject.stub :all_by_key => ['test'], :all => ['test_resource']
32
+ expect(subject.equals?(:keys => 'test')).to be_true
33
+ end
34
+ end
35
+ end