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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61c1f9349ff77a468315fe6f7666e45e4009467a
4
- data.tar.gz: b4df26ffef56668555305cbc9b5eae41a92a0738
3
+ metadata.gz: 97d0436598f0439f4d63729eba87f983b5a5a569
4
+ data.tar.gz: 61b7da80bc5e131b7e058234a7cbc2bfdedd9620
5
5
  SHA512:
6
- metadata.gz: 599b28d68053b6c8fc5432bacc5f11a65b205343874e2433c824f615ad43c1bfd9c71729c3dfad98ad4c3568498e242b5df5c42798aed9f61452a932ad3eb3a2
7
- data.tar.gz: 6df2de8ba7d4d83652737b29b512a9e984fee23fbd8af0b93f6084b1307a9fef6daf4b592344ca292d3a9d3c6bf76e1f02845079a8024aee203c1c099d427e14
6
+ metadata.gz: a02f1c12494ac3c18637c4294c5ae80df73b354836fa58918f60eb4b57b0a6184cbe462a437907cf1d9712cae775b1bcac1c7338ee417a128f66f930d30c734c
7
+ data.tar.gz: 150e479220d830a9a40ea3952df9ff9047650addc62a75743d0ac60f197e92dd2fa15e07ae73f09e3fcc40927525ea1e2f752c2f8261f94f233213b5405b545e
@@ -7,7 +7,7 @@ module Awspec
7
7
  class_option :profile
8
8
 
9
9
  types = %w(
10
- vpc ec2 rds security_group elb network_acl
10
+ vpc ec2 rds security_group elb network_acl route_table
11
11
  )
12
12
 
13
13
  types.each do |type|
@@ -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
@@ -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'
@@ -6,4 +6,8 @@ RSpec::Matchers.define :have_route do |target|
6
6
  chain :destination do |destination|
7
7
  @destination = destination
8
8
  end
9
+
10
+ chain :destination_cidr_block do |destination|
11
+ @destination = destination
12
+ end
9
13
  end
@@ -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
  {
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.20.1'
2
+ VERSION = '0.20.2'
3
3
  end
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.1
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 00:00:00.000000000 Z
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