Sha256: 8909a2f59e81e98a1bce94a878ae20527809d2451dd8e733de7ec64cb15153c9
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
module Awspec::Generator module Spec class S3Bucket include Awspec::Helper::Finder def generate_all buckets = select_all_buckets buckets.empty? && fail('Not Found Bucket') specs = buckets.map do |bucket| acl = find_bucket_acl(bucket.name) grant_specs = generate_grant_specs(acl) content = ERB.new(bucket_spec_template, nil, '-').result(binding).gsub(/^\n/, '') end specs.join("\n") end def generate_grant_specs(acl) linespecs = [] acl.grants.each do |grant| linespecs.push(ERB.new(grant_linetemplate, nil, '-').result(binding)) end linespecs end def grant_linetemplate grantee = 'grant.grantee.display_name || grant.grantee.uri || grant.grantee.id' template = <<-EOF it { should have_acl_grant(grantee: '<%= #{grantee} %>', permission: '<%= grant.permission %>') } EOF template end def bucket_spec_template template = <<-'EOF' describe s3_bucket('<%= bucket.name %>') do it { should exist } its(:acl_owner) { should eq '<%= acl.owner.display_name %>' } its(:acl_grants_count) { should eq <%= acl.grants.count %> } <% grant_specs.each do |line| %> <%= line %> <% end %> end EOF template end end end end
Version data entries
4 entries across 4 versions & 1 rubygems