awspec 0.20.1 → 0.20.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awspec/command/generate.rb +1 -1
- data/lib/awspec/generator/spec/route_table.rb +59 -0
- data/lib/awspec/generator.rb +1 -0
- data/lib/awspec/matcher/have_route.rb +4 -0
- data/lib/awspec/stub/route_table.rb +15 -0
- data/lib/awspec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97d0436598f0439f4d63729eba87f983b5a5a569
|
4
|
+
data.tar.gz: 61b7da80bc5e131b7e058234a7cbc2bfdedd9620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a02f1c12494ac3c18637c4294c5ae80df73b354836fa58918f60eb4b57b0a6184cbe462a437907cf1d9712cae775b1bcac1c7338ee417a128f66f930d30c734c
|
7
|
+
data.tar.gz: 150e479220d830a9a40ea3952df9ff9047650addc62a75743d0ac60f197e92dd2fa15e07ae73f09e3fcc40927525ea1e2f752c2f8261f94f233213b5405b545e
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class RouteTable
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_by_vpc_id(vpc_id)
|
6
|
+
describes = %w(
|
7
|
+
)
|
8
|
+
vpc = find_vpc(vpc_id)
|
9
|
+
fail 'Not Found VPC' unless vpc
|
10
|
+
@vpc_id = vpc[:vpc_id]
|
11
|
+
@vpc_tag_name = vpc.tag_name
|
12
|
+
route_tables = select_route_table_by_vpc_id(@vpc_id)
|
13
|
+
specs = route_tables.map do |route_table|
|
14
|
+
linespecs = generate_linespecs(route_table)
|
15
|
+
route_table_id = route_table[:route_table_id]
|
16
|
+
route_table_tag_name = route_table.tag_name
|
17
|
+
content = ERB.new(route_table_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
|
18
|
+
end
|
19
|
+
specs.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_linespecs(route_table)
|
23
|
+
linespecs = []
|
24
|
+
route_table.routes.each do |route|
|
25
|
+
linespecs.push(ERB.new(route_table_spec_linetemplate, nil, '-').result(binding))
|
26
|
+
end
|
27
|
+
linespecs
|
28
|
+
end
|
29
|
+
|
30
|
+
def route_table_spec_linetemplate
|
31
|
+
template = <<-'EOF'
|
32
|
+
it { shold have_route('<%= route.gateway_id %>').destination('<%= route.destination_cidr_block %>') }
|
33
|
+
EOF
|
34
|
+
template
|
35
|
+
end
|
36
|
+
|
37
|
+
def route_table_spec_template
|
38
|
+
template = <<-'EOF'
|
39
|
+
<%- if route_table_tag_name -%>
|
40
|
+
describe route_table('<%= route_table_tag_name %>') do
|
41
|
+
<%- else -%>
|
42
|
+
describe route_table('<%= route_table_id %>') do
|
43
|
+
<%- end -%>
|
44
|
+
it { should exist }
|
45
|
+
<%- if @vpc_tag_name -%>
|
46
|
+
it { should belong_to_vpc('<%= @vpc_tag_name %>') }
|
47
|
+
<%- else -%>
|
48
|
+
it { should belong_to_vpc('<%= @vpc_id %>') }
|
49
|
+
<%- end -%>
|
50
|
+
<% linespecs.each do |line| %>
|
51
|
+
<%= line %>
|
52
|
+
<% end %>
|
53
|
+
end
|
54
|
+
EOF
|
55
|
+
template
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/awspec/generator.rb
CHANGED
@@ -10,6 +10,7 @@ require 'awspec/generator/spec/elb'
|
|
10
10
|
require 'awspec/generator/spec/iam_policy'
|
11
11
|
require 'awspec/generator/spec/cloudwatch_alarm'
|
12
12
|
require 'awspec/generator/spec/network_acl'
|
13
|
+
require 'awspec/generator/spec/route_table'
|
13
14
|
|
14
15
|
# Doc
|
15
16
|
require 'awspec/generator/doc/type'
|
@@ -1,5 +1,20 @@
|
|
1
1
|
Aws.config[:ec2] = {
|
2
2
|
stub_responses: {
|
3
|
+
describe_vpcs: {
|
4
|
+
vpcs: [
|
5
|
+
{
|
6
|
+
vpc_id: 'vpc-ab123cde',
|
7
|
+
state: 'available',
|
8
|
+
cidr_block: '10.0.0.0/16',
|
9
|
+
tags: [
|
10
|
+
{
|
11
|
+
key: 'Name',
|
12
|
+
value: 'my-vpc'
|
13
|
+
}
|
14
|
+
]
|
15
|
+
}
|
16
|
+
]
|
17
|
+
},
|
3
18
|
describe_route_tables: {
|
4
19
|
route_tables: [
|
5
20
|
{
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/awspec/generator/spec/network_acl.rb
|
220
220
|
- lib/awspec/generator/spec/rds.rb
|
221
221
|
- lib/awspec/generator/spec/route53_hosted_zone.rb
|
222
|
+
- lib/awspec/generator/spec/route_table.rb
|
222
223
|
- lib/awspec/generator/spec/security_group.rb
|
223
224
|
- lib/awspec/generator/spec/vpc.rb
|
224
225
|
- lib/awspec/generator/template.rb
|