awspec 1.14.0 → 1.14.1

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
- SHA1:
3
- metadata.gz: '02079c9922dca56746510acc4b39754b272ac5a4'
4
- data.tar.gz: 74e3e1c789724abfafd496dbabbfb351d1cb2f42
2
+ SHA256:
3
+ metadata.gz: c4536062b8c2373a53257e7371fd3e64cbd5f72d4723fd9f096a445e356f13a6
4
+ data.tar.gz: d7229d5dc7402eccf5c1b4606f1ab75284c8d97932e5e894a7d613ae245d07d7
5
5
  SHA512:
6
- metadata.gz: 3657fdcfd445899ba09db82190e34290e0263100358cb77ad3c520a339f425cda0ab6ff745bf7cf96405ce18a4586d89ab6ae339290e1fe8c744ff28868aff11
7
- data.tar.gz: eb5233b347173d62d76b8a0d2492983f5b764ee7d970c612f4a49fea8234b61dd7cf50f006a2de05767b9cd387f7b084d273aed548d68c02610089c1176c282f
6
+ metadata.gz: b860135847a62df4219e064219985b52b86c31de640414be02c50d24e0a495404dcaf56ceb22002ce563b9e683c1ad2c86127b4272e9f7386142163f579ccca9
7
+ data.tar.gz: 98835ccad4c01e7cd0f39b643b81ea9d5f00459204822ab9572dec11c9bdbdcd59015e2815a62e9a653271423e3c09f5e3141c867e9d51842d4214b30fef4ae1
@@ -6,6 +6,35 @@ describe lambda('my-lambda-function-name') do
6
6
  end
7
7
  ```
8
8
 
9
+ ### have_env_vars
10
+
11
+ Useful to validate if there are environment variables configured in the Lambda:
12
+
13
+ ```ruby
14
+ describe lambda('my-lambda-function-name') do
15
+ it { should have_env_vars() }
16
+ end
17
+ ```
18
+
19
+ ### have_env_var
20
+
21
+ Useful to validate if there is a specific environment variable declared in the Lambda. You probably will want to use it with `have_env_var_value`.
22
+
23
+ ## have_env_var_value
24
+
25
+ Validates if a specific environment variable has the expected value. More useful to use with `have_env_var` because if the variable isn't available, it will fail without notifying that the variable is missing.
26
+
27
+ ```ruby
28
+ expected.each_pair do |key, value|
29
+ context "environment variable #{key}" do
30
+ it { should have_env_var(key) }
31
+ it { should have_env_var_value(key, value) }
32
+ end
33
+ end
34
+ ```
35
+
36
+ `expected` would be a hash that has the environment variables names as keys.
37
+
9
38
  ### have_event_source
10
39
 
11
- This matcher does not support Amazon S3 event sources. ( [See SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method) )
40
+ This matcher does not support Amazon S3 event sources ([see SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method)).
@@ -2017,11 +2017,42 @@ end
2017
2017
  ```
2018
2018
 
2019
2019
 
2020
+ ### have_env_var
2021
+
2022
+ Useful to validate if there is a specific environment variable declared in the Lambda. You probably will want to use it with `have_env_var_value`.
2023
+
2024
+ ## have_env_var_value
2025
+
2026
+ Validates if a specific environment variable has the expected value. More useful to use with `have_env_var` because if the variable isn't available, it will fail without notifying that the variable is missing.
2027
+
2028
+ ```ruby
2029
+ expected.each_pair do |key, value|
2030
+ context "environment variable #{key}" do
2031
+ it { should have_env_var(key) }
2032
+ it { should have_env_var_value(key, value) }
2033
+ end
2034
+ end
2035
+ ```
2036
+
2037
+ `expected` would be a hash that has the environment variables names as keys.
2038
+
2039
+
2040
+ ### have_env_vars
2041
+
2042
+ Useful to validate if there are environment variables configured in the Lambda:
2043
+
2044
+ ```ruby
2045
+ describe lambda('my-lambda-function-name') do
2046
+ it { should have_env_vars() }
2047
+ end
2048
+ ```
2049
+
2050
+
2020
2051
  ### have_event_source
2021
2052
 
2022
- This matcher does not support Amazon S3 event sources. ( [See SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method) )
2053
+ This matcher does not support Amazon S3 event sources ([see SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method)).
2023
2054
 
2024
- ### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified), its(:code_sha_256), its(:version), its(:vpc_config), its(:dead_letter_config), its(:environment), its(:kms_key_arn), its(:tracing_config), its(:master_arn), its(:revision_id), its(:layers)
2055
+ ### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified), its(:code_sha_256), its(:version), its(:vpc_config), its(:dead_letter_config), its(:kms_key_arn), its(:master_arn), its(:revision_id), its(:layers)
2025
2056
  ## <a name="launch_configuration">launch_configuration</a>
2026
2057
 
2027
2058
  LaunchConfiguration resource type.
@@ -7,7 +7,7 @@ module Awspec::Generator
7
7
  @type_name = 'Lambda'
8
8
  @type = Awspec::Type::Lambda.new('my-lambda-function-name')
9
9
  @ret = @type.resource_via_client
10
- @matchers = []
10
+ @matchers = %w(have_env_var have_env_vars)
11
11
  @ignore_matchers = []
12
12
  @describes = []
13
13
  end
@@ -78,3 +78,8 @@ require 'awspec/matcher/have_subscription_attributes'
78
78
  # Redshift
79
79
  require 'awspec/matcher/belong_to_cluster_subnet_group'
80
80
  require 'awspec/matcher/have_cluster_parameter_group'
81
+
82
+ # Lambda
83
+ require 'awspec/matcher/have_env_vars'
84
+ require 'awspec/matcher/have_env_var'
85
+ require 'awspec/matcher/have_env_var_value'
@@ -0,0 +1,9 @@
1
+ RSpec::Matchers.define :have_env_var do |env_var|
2
+ match do |lambda_function|
3
+ lambda_function.environment.variables.key?(env_var)
4
+ end
5
+
6
+ description do
7
+ 'exist'
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ RSpec::Matchers.define :have_env_var_value do |env_var, value|
2
+ match do |lambda_function|
3
+ if lambda_function.environment.variables.key?(env_var)
4
+ lambda_function.environment.variables[env_var] == value
5
+ else
6
+ false
7
+ end
8
+ end
9
+
10
+ description do
11
+ "have the value #{value}"
12
+ end
13
+
14
+ failure_message do |lambda_function|
15
+ current_value = lambda_function.environment.variables[env_var]
16
+ "Environment variable #{env_var} don't have the value #{value}, but #{current_value}"
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :have_env_vars do
2
+ match do |lambda_function|
3
+ !lambda_function.environment.variables.empty?
4
+ end
5
+ end
@@ -10,7 +10,33 @@ Aws.config[:lambda] = {
10
10
  handler: 'lambda_function.lambda_handler',
11
11
  timeout: 5,
12
12
  memory_size: 256,
13
- code_size: 1234
13
+ code_size: 1234,
14
+ last_modified: Time.new(2018, 12, 05, 19, 10, 44, '+00:00'),
15
+ code_sha_256: 'LAI9GRLpJD/dq2D7Uopwaeh354tsd8fQsSI6eSH0xOIs=',
16
+ version: '$LATEST',
17
+ role: 'arn:aws:iam::123456789:role/foobarVPCRole',
18
+ kms_key_arn: nil,
19
+ revision_id: '8d01897515-bcb0-43c7-9b14-e6d14fyyff4d',
20
+ layers: nil,
21
+ tracing_config:
22
+ # <struct Aws::Lambda::Types::TracingConfigResponse mode="PassThrough">
23
+ {
24
+ mode: 'PassThrough'
25
+ },
26
+ environment:
27
+ # <struct Aws::Lambda::Types::EnvironmentResponse
28
+ {
29
+ variables:
30
+ {
31
+ 'ENDPOINT_URL' => 'https://foobar.sns.us-east-1.vpce.amazonaws.com',
32
+ 'ENV_NAME' => 'QA',
33
+ 'LOG_LEVEL' => 'DEBUG',
34
+ 'FOOBAR_TOPIC' => 'arn:aws:sns:us-east-1:123456789:FoobarManager',
35
+ 'RESOLVER1' => '10.196.138.1',
36
+ 'RESOLVER2' => '10.196.136.2'
37
+ },
38
+ error: nil
39
+ }
14
40
  }
15
41
  ]
16
42
  },
@@ -49,5 +49,11 @@ module Awspec::Type
49
49
  end
50
50
 
51
51
  undef :timeout
52
+
53
+ private
54
+
55
+ def check_existence
56
+ raise Awspec::NoExistingResource.new(self.class, @display_name) if resource_via_client.nil?
57
+ end
52
58
  end
53
59
  end
@@ -56,11 +56,5 @@ module Awspec::Type
56
56
  !roles.empty?
57
57
  end
58
58
  end
59
-
60
- private
61
-
62
- def check_existence
63
- raise Awspec::NoExistingResource.new(self.class, @display_name) if resource_via_client.nil?
64
- end
65
59
  end
66
60
  end
@@ -9,6 +9,7 @@ module Awspec::Type
9
9
  end
10
10
 
11
11
  def timeout
12
+ check_existence
12
13
  resource_via_client.timeout
13
14
  end
14
15
 
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.14.0'
2
+ VERSION = '1.14.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: 1.14.0
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-07 00:00:00.000000000 Z
11
+ date: 2019-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -492,6 +492,9 @@ files:
492
492
  - lib/awspec/matcher/have_cluster_parameter_group.rb
493
493
  - lib/awspec/matcher/have_custom_response_error_code.rb
494
494
  - lib/awspec/matcher/have_db_parameter_group.rb
495
+ - lib/awspec/matcher/have_env_var.rb
496
+ - lib/awspec/matcher/have_env_var_value.rb
497
+ - lib/awspec/matcher/have_env_vars.rb
495
498
  - lib/awspec/matcher/have_inline_policy.rb
496
499
  - lib/awspec/matcher/have_key_policy.rb
497
500
  - lib/awspec/matcher/have_key_schema.rb
@@ -688,7 +691,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
688
691
  version: '0'
689
692
  requirements: []
690
693
  rubyforge_project:
691
- rubygems_version: 2.6.14
694
+ rubygems_version: 2.7.6
692
695
  signing_key:
693
696
  specification_version: 4
694
697
  summary: RSpec tests for your AWS resources.