From 16d04ff18ce4fdd3d3cd828b549e237fb091d457 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Tue, 15 Jan 2019 17:21:46 -0800 Subject: [PATCH 1/3] Define rubocop target ruby version to 2.4 Signed-off-by: Sam Levenick --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 1803e814a..2f5a0fc4a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,6 @@ --- AllCops: + TargetRubyVersion: 2.4 Exclude: - Gemfile - Rakefile From c85a01fa72576a85a977e4ff18bc75023871de09 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 16 Jan 2019 00:42:51 +0000 Subject: [PATCH 2/3] Update pubsub to pull gcp project id from correct spot Signed-off-by: Modular Magician --- docs/resources/google_pubsub_subscription.md | 5 ++++- docs/resources/google_pubsub_subscriptions.md | 6 +++--- docs/resources/google_pubsub_topic.md | 5 ++++- docs/resources/google_pubsub_topics.md | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/resources/google_pubsub_subscription.md b/docs/resources/google_pubsub_subscription.md index 71dd45121..fcd41e9c0 100644 --- a/docs/resources/google_pubsub_subscription.md +++ b/docs/resources/google_pubsub_subscription.md @@ -9,10 +9,13 @@ A `google_pubsub_subscription` is used to test a Google Subscription resource ## Examples ``` -describe google_pubsub_subscription(project: '', name: 'inspec-gcp-subscription') do +describe google_pubsub_subscription(project: ''chef-gcp-inspec'', name: 'inspec-gcp-subscription') do it { should exist } end +describe google_pubsub_subscription(project: ''chef-gcp-inspec'', name: 'nonexistent') do + it { should_not exist } +end ``` ## Properties diff --git a/docs/resources/google_pubsub_subscriptions.md b/docs/resources/google_pubsub_subscriptions.md index c00553938..4203af095 100644 --- a/docs/resources/google_pubsub_subscriptions.md +++ b/docs/resources/google_pubsub_subscriptions.md @@ -9,13 +9,13 @@ A `google_pubsub_subscriptions` is used to test a Google Subscription resource ## Examples ``` -describe google_pubsub_subscriptions(project: '') do +describe google_pubsub_subscriptions(project: ''chef-gcp-inspec'') do it { should exist } its('count') { should eq 1 } end -google_pubsub_subscriptions(project: '').names.each do |subscription_name| - describe google_pubsub_subscription(project: '', name: subscription_name) do +google_pubsub_subscriptions(project: ''chef-gcp-inspec'').names.each do |subscription_name| + describe google_pubsub_subscription(project: ''chef-gcp-inspec'', name: subscription_name) do its('name') { should match /#{'inspec-gcp-subscription'}/ } end end diff --git a/docs/resources/google_pubsub_topic.md b/docs/resources/google_pubsub_topic.md index 622a8f8c2..7a70efbfc 100644 --- a/docs/resources/google_pubsub_topic.md +++ b/docs/resources/google_pubsub_topic.md @@ -9,10 +9,13 @@ A `google_pubsub_topic` is used to test a Google Topic resource ## Examples ``` -describe google_pubsub_topic(project: '', name: 'inspec-gcp-topic') do +describe google_pubsub_topic(project: ''chef-gcp-inspec'', name: 'inspec-gcp-topic') do it { should exist } end +describe google_pubsub_topic(project: ''chef-gcp-inspec'', name: 'nonexistent') do + it { should_not exist } +end ``` ## Properties diff --git a/docs/resources/google_pubsub_topics.md b/docs/resources/google_pubsub_topics.md index 6f49ea310..07658cf11 100644 --- a/docs/resources/google_pubsub_topics.md +++ b/docs/resources/google_pubsub_topics.md @@ -9,14 +9,14 @@ A `google_pubsub_topics` is used to test a Google Topic resource ## Examples ``` -describe google_pubsub_topics(project: '') do +describe google_pubsub_topics(project: ''chef-gcp-inspec'') do it { should exist } its('names') { should include 'inspec-gcp-topic' } its('count') { should eq 1 } end -google_pubsub_topics(project: '').names.each do |topic_name| - describe google_pubsub_topic(project: '', name: topic_name) do +google_pubsub_topics(project: ''chef-gcp-inspec'').names.each do |topic_name| + describe google_pubsub_topic(project: ''chef-gcp-inspec'', name: topic_name) do its('name') { should eq 'inspec-gcp-topic' } end end From 46a9cbef4bf9bfd9822d25110b7b5ff02cd5c1f2 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 16 Jan 2019 18:08:30 +0000 Subject: [PATCH 3/3] Actually use memoized variables Signed-off-by: Modular Magician --- docs/resources/google_pubsub_subscription.md | 4 ++-- docs/resources/google_pubsub_subscriptions.md | 8 ++++---- docs/resources/google_pubsub_topic.md | 4 ++-- docs/resources/google_pubsub_topics.md | 6 +++--- .../verify/controls/google_pubsub_subscriptions.rb | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/resources/google_pubsub_subscription.md b/docs/resources/google_pubsub_subscription.md index fcd41e9c0..9762a829d 100644 --- a/docs/resources/google_pubsub_subscription.md +++ b/docs/resources/google_pubsub_subscription.md @@ -9,11 +9,11 @@ A `google_pubsub_subscription` is used to test a Google Subscription resource ## Examples ``` -describe google_pubsub_subscription(project: ''chef-gcp-inspec'', name: 'inspec-gcp-subscription') do +describe google_pubsub_subscription(project: 'chef-gcp-inspec', name: 'inspec-gcp-subscription') do it { should exist } end -describe google_pubsub_subscription(project: ''chef-gcp-inspec'', name: 'nonexistent') do +describe google_pubsub_subscription(project: 'chef-gcp-inspec', name: 'nonexistent') do it { should_not exist } end ``` diff --git a/docs/resources/google_pubsub_subscriptions.md b/docs/resources/google_pubsub_subscriptions.md index 4203af095..3213eb84c 100644 --- a/docs/resources/google_pubsub_subscriptions.md +++ b/docs/resources/google_pubsub_subscriptions.md @@ -9,14 +9,14 @@ A `google_pubsub_subscriptions` is used to test a Google Subscription resource ## Examples ``` -describe google_pubsub_subscriptions(project: ''chef-gcp-inspec'') do +describe google_pubsub_subscriptions(project: 'chef-gcp-inspec') do it { should exist } its('count') { should eq 1 } end -google_pubsub_subscriptions(project: ''chef-gcp-inspec'').names.each do |subscription_name| - describe google_pubsub_subscription(project: ''chef-gcp-inspec'', name: subscription_name) do - its('name') { should match /#{'inspec-gcp-subscription'}/ } +google_pubsub_subscriptions(project: 'chef-gcp-inspec').names.each do |subscription_name| + describe google_pubsub_subscription(project: 'chef-gcp-inspec', name: subscription_name) do + it { should exist } end end diff --git a/docs/resources/google_pubsub_topic.md b/docs/resources/google_pubsub_topic.md index 7a70efbfc..dcfe05efb 100644 --- a/docs/resources/google_pubsub_topic.md +++ b/docs/resources/google_pubsub_topic.md @@ -9,11 +9,11 @@ A `google_pubsub_topic` is used to test a Google Topic resource ## Examples ``` -describe google_pubsub_topic(project: ''chef-gcp-inspec'', name: 'inspec-gcp-topic') do +describe google_pubsub_topic(project: 'chef-gcp-inspec', name: 'inspec-gcp-topic') do it { should exist } end -describe google_pubsub_topic(project: ''chef-gcp-inspec'', name: 'nonexistent') do +describe google_pubsub_topic(project: 'chef-gcp-inspec', name: 'nonexistent') do it { should_not exist } end ``` diff --git a/docs/resources/google_pubsub_topics.md b/docs/resources/google_pubsub_topics.md index 07658cf11..888a844ae 100644 --- a/docs/resources/google_pubsub_topics.md +++ b/docs/resources/google_pubsub_topics.md @@ -9,14 +9,14 @@ A `google_pubsub_topics` is used to test a Google Topic resource ## Examples ``` -describe google_pubsub_topics(project: ''chef-gcp-inspec'') do +describe google_pubsub_topics(project: 'chef-gcp-inspec') do it { should exist } its('names') { should include 'inspec-gcp-topic' } its('count') { should eq 1 } end -google_pubsub_topics(project: ''chef-gcp-inspec'').names.each do |topic_name| - describe google_pubsub_topic(project: ''chef-gcp-inspec'', name: topic_name) do +google_pubsub_topics(project: 'chef-gcp-inspec').names.each do |topic_name| + describe google_pubsub_topic(project: 'chef-gcp-inspec', name: topic_name) do its('name') { should eq 'inspec-gcp-topic' } end end diff --git a/test/integration/verify/controls/google_pubsub_subscriptions.rb b/test/integration/verify/controls/google_pubsub_subscriptions.rb index f90f2f59b..5061aa2e1 100644 --- a/test/integration/verify/controls/google_pubsub_subscriptions.rb +++ b/test/integration/verify/controls/google_pubsub_subscriptions.rb @@ -28,7 +28,7 @@ google_pubsub_subscriptions(project: gcp_project_id).names.each do |subscription_name| describe google_pubsub_subscription(project: gcp_project_id, name: subscription_name) do - its('name') { should match /#{subscription['name']}/ } + it { should exist } end end end