awspec 0.77.1 → 0.78.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 635c4acd55ea9607b2e07d60f3fb376ec5d8e1dc
4
- data.tar.gz: e05dd8f287a940568be8c7fae2931b0c5ba096a3
3
+ metadata.gz: 4f08be5007eab85649b34cab6ed8502adc6c49b5
4
+ data.tar.gz: 027a66e2d90b89ba33ac0b6cbcb8d8cd0c3c7491
5
5
  SHA512:
6
- metadata.gz: c88de65ec76d4c16f82b95a98b32ce1ad351a6d988ea50da38c04625dc79492002872bebef973093df774fc03dd4a42d4856470da6734d2a45212bd1990f32ac
7
- data.tar.gz: 12601400238291a9952939963e8b544eba57a1782b1fcf524144b7b2fc98e5728fe04cfe0181acd16024b6915a37fafeed98331380108973c1030494d10d3197
6
+ metadata.gz: cb0870edb649575f61bca1ccb9ce5f55d1b81d32ec3f60f9bf5dbaae4753a385163ef2e702af04b550fce94bb5e7e674c3616f74dc9f26147cde65d83e3bb421
7
+ data.tar.gz: 0cc0688e5f9f023136602f86cd27e991b658c312683b249b52619deaeaadb825ef021c4177fec1a6310ea0d38cb000585406cfc21bf45d5d2502e0879a83b8ae
@@ -0,0 +1,23 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe eip('123.0.456.789') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_associated_to
10
+
11
+ ```ruby
12
+ describe eip('123.0.456.789') do
13
+ it { should be_associated_to('i-ec12345a') }
14
+ end
15
+ ```
16
+
17
+ ### belong_to_domain
18
+
19
+ ```ruby
20
+ describe eip('123.0.456.789') do
21
+ it { should belong_to_domain('vpc') }
22
+ end
23
+ ```
@@ -20,6 +20,7 @@
20
20
  | [ecs_service](#ecs_service)
21
21
  | [ecs_task_definition](#ecs_task_definition)
22
22
  | [efs](#efs)
23
+ | [eip](#eip)
23
24
  | [elasticache](#elasticache)
24
25
  | [elasticache_cache_parameter_group](#elasticache_cache_parameter_group)
25
26
  | [elasticsearch](#elasticsearch)
@@ -865,6 +866,37 @@ end
865
866
  ```
866
867
 
867
868
  ### its(:owner_id), its(:creation_token), its(:file_system_id), its(:creation_time), its(:life_cycle_state), its(:name), its(:number_of_mount_targets), its(:performance_mode)
869
+ ## <a name="elastic_ip">elastic_ip</a>
870
+
871
+ Elastic IP resource type.
872
+
873
+ ### exist
874
+
875
+ ```ruby
876
+ describe eip('123.0.456.789') do
877
+ it { should exist }
878
+ end
879
+ ```
880
+
881
+
882
+ ### be_associated_to
883
+
884
+ ```ruby
885
+ describe eip('123.0.456.789') do
886
+ it { should be_associated_to('i-ec12345a') }
887
+ end
888
+ ```
889
+
890
+
891
+ ### belong_to_domain
892
+
893
+ ```ruby
894
+ describe eip('123.0.456.789') do
895
+ it { should belong_to_domain('vpc') }
896
+ end
897
+ ```
898
+
899
+
868
900
  ## <a name="elasticache">elasticache</a>
869
901
 
870
902
  Elasticache resource type.
@@ -39,7 +39,7 @@ module Awspec
39
39
  types_for_generate_all = %w(
40
40
  cloudwatch_alarm cloudwatch_event directconnect ebs efs
41
41
  elasticsearch iam_group iam_policy iam_role iam_user kms lambda
42
- acm cloudwatch_logs
42
+ acm cloudwatch_logs eip
43
43
  )
44
44
 
45
45
  types_for_generate_all.each do |type|
@@ -27,6 +27,7 @@ require 'awspec/generator/spec/cloudwatch_logs'
27
27
  require 'awspec/generator/spec/alb'
28
28
  require 'awspec/generator/spec/internet_gateway'
29
29
  require 'awspec/generator/spec/elasticsearch'
30
+ require 'awspec/generator/spec/eip'
30
31
 
31
32
  # Doc
32
33
  require 'awspec/generator/doc/type'
@@ -0,0 +1,17 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class Eip < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'Elastic IP'
8
+ @type = Awspec::Type::Eip.new('123.0.456.789')
9
+ @ret = @type.resource_via_client
10
+ @matchers = ['belong_to_domain']
11
+ @ignore_matchers = []
12
+ @describes = []
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module Awspec::Generator
2
+ module Spec
3
+ class Eip
4
+ include Awspec::Helper::Finder
5
+ def select_all_addresses
6
+ res = ec2_client.describe_addresses
7
+ res.addresses
8
+ end
9
+
10
+ def generate_all
11
+ eips = select_all_addresses
12
+ raise 'Not Found Elastic IP addresses.' if eips.empty?
13
+ ERB.new(eip_spec_template, nil, '-').result(binding).chomp
14
+ end
15
+
16
+ def eip_spec_template
17
+ template = <<-'EOF'
18
+ <% eips.each do |eip| %>
19
+ describe eip('<%= eip.public_ip %>') do
20
+ it { should exist }
21
+ it { should be_associated_to('<%= eip.instance_id %>') }
22
+ it { should belong_to_domain('<%= eip.domain %>') }
23
+ end
24
+ <% end %>
25
+ EOF
26
+ template
27
+ end
28
+ end
29
+ end
30
+ end
@@ -109,6 +109,13 @@ module Awspec::Helper
109
109
  res.addresses
110
110
  end
111
111
 
112
+ def select_eip_by_public_ip(id)
113
+ res = ec2_client.describe_addresses({
114
+ filters: [{ name: 'public-ip', values: [id] }]
115
+ })
116
+ res.addresses
117
+ end
118
+
112
119
  def select_network_interface_by_instance_id(id)
113
120
  res = ec2_client.describe_network_interfaces({
114
121
  filters: [{ name: 'attachment.instance-id', values: [id] }]
@@ -15,7 +15,7 @@ module Awspec
15
15
  network_acl network_interface rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
16
16
  route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
17
17
  elastictranscoder_pipeline waf_web_acl customer_gateway vpn_gateway vpn_connection internet_gateway acm
18
- cloudwatch_logs dynamodb_table
18
+ cloudwatch_logs dynamodb_table eip
19
19
  )
20
20
 
21
21
  ACCOUNT_ATTRIBUTES = %w(
@@ -54,3 +54,6 @@ require 'awspec/matcher/have_subscription_filter'
54
54
  # DynamoDB
55
55
  require 'awspec/matcher/have_attribute_definition'
56
56
  require 'awspec/matcher/have_key_schema'
57
+
58
+ # EIP
59
+ require 'awspec/matcher/belong_to_domain'
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :belong_to_domain do |domain|
2
+ match do |type|
3
+ return true if type.resource_via_client.last[:domain] == domain
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ Aws.config[:ec2] = {
2
+ stub_responses: {
3
+ describe_addresses: {
4
+ addresses: [
5
+ {
6
+ domain: 'vpc',
7
+ public_ip: '123.0.456.789',
8
+ instance_id: 'i-ec12345a'
9
+ }
10
+ ]
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,16 @@
1
+ module Awspec::Type
2
+ class Eip < ResourceBase
3
+ def resource_via_client
4
+ @resource_via_client ||= select_eip_by_public_ip(@display_name)
5
+ end
6
+
7
+ def id
8
+ @id ||= resource_via_client.last.public_ip if resource_via_client
9
+ end
10
+
11
+ def associated_to?(instance_id)
12
+ return false unless resource_via_client.last.instance_id == instance_id
13
+ resource_via_client.last.instance_id == instance_id
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.77.1'
2
+ VERSION = '0.78.1'
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.77.1
4
+ version: 0.78.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-23 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -225,6 +225,7 @@ files:
225
225
  - doc/_resource_types/ecs_service.md
226
226
  - doc/_resource_types/ecs_task_definition.md
227
227
  - doc/_resource_types/efs.md
228
+ - doc/_resource_types/eip.md
228
229
  - doc/_resource_types/elasticache.md
229
230
  - doc/_resource_types/elasticache_cache_parameter_group.md
230
231
  - doc/_resource_types/elasticsearch.md
@@ -295,6 +296,7 @@ files:
295
296
  - lib/awspec/generator/doc/type/ecs_service.rb
296
297
  - lib/awspec/generator/doc/type/ecs_task_definition.rb
297
298
  - lib/awspec/generator/doc/type/efs.rb
299
+ - lib/awspec/generator/doc/type/eip.rb
298
300
  - lib/awspec/generator/doc/type/elasticache.rb
299
301
  - lib/awspec/generator/doc/type/elasticache_cache_parameter_group.rb
300
302
  - lib/awspec/generator/doc/type/elasticsearch.rb
@@ -336,6 +338,7 @@ files:
336
338
  - lib/awspec/generator/spec/ebs.rb
337
339
  - lib/awspec/generator/spec/ec2.rb
338
340
  - lib/awspec/generator/spec/efs.rb
341
+ - lib/awspec/generator/spec/eip.rb
339
342
  - lib/awspec/generator/spec/elasticsearch.rb
340
343
  - lib/awspec/generator/spec/elb.rb
341
344
  - lib/awspec/generator/spec/iam_group.rb
@@ -401,6 +404,7 @@ files:
401
404
  - lib/awspec/matcher/be_opened_only.rb
402
405
  - lib/awspec/matcher/belong_to_cache_subnet_group.rb
403
406
  - lib/awspec/matcher/belong_to_db_subnet_group.rb
407
+ - lib/awspec/matcher/belong_to_domain.rb
404
408
  - lib/awspec/matcher/belong_to_iam_group.rb
405
409
  - lib/awspec/matcher/belong_to_metric.rb
406
410
  - lib/awspec/matcher/belong_to_replication_group.rb
@@ -446,6 +450,7 @@ files:
446
450
  - lib/awspec/stub/ecs_service.rb
447
451
  - lib/awspec/stub/ecs_task_definition.rb
448
452
  - lib/awspec/stub/efs.rb
453
+ - lib/awspec/stub/eip.rb
449
454
  - lib/awspec/stub/elasticache.rb
450
455
  - lib/awspec/stub/elasticache_cache_parameter_group.rb
451
456
  - lib/awspec/stub/elasticsearch.rb
@@ -501,6 +506,7 @@ files:
501
506
  - lib/awspec/type/ecs_service.rb
502
507
  - lib/awspec/type/ecs_task_definition.rb
503
508
  - lib/awspec/type/efs.rb
509
+ - lib/awspec/type/eip.rb
504
510
  - lib/awspec/type/elasticache.rb
505
511
  - lib/awspec/type/elasticache_cache_parameter_group.rb
506
512
  - lib/awspec/type/elasticsearch.rb
@@ -555,7 +561,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
555
561
  version: '0'
556
562
  requirements: []
557
563
  rubyforge_project:
558
- rubygems_version: 2.5.2
564
+ rubygems_version: 2.6.12
559
565
  signing_key:
560
566
  specification_version: 4
561
567
  summary: RSpec tests for your AWS resources.