Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChefSpec matcher #29

Merged
merged 3 commits into from
Oct 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ To create your cipher, run `bin/s3_crypto -g > my_new_key` and a new 256-bit (32
Try `bin/s3_crypto -g > my_new_key`.

You can use the utility `bin/s3_crypto` to encrypt files prior to uploading to S3 and to decrypt files prior to make sure the encryption is working.

= ChefSpec matcher
s3_file comes with a matcher to use in {ChefSpec}[https://github.com/sethvargo/chefspec].

This spec checks the code from the USAGE example above:

it 'downloads some file from s3' do
expect(chef_run).to create_s3_file('/tmp/somefile')
.with(bucket: "my-s3-bucket", remote_path: "/my/s3/key")
end

5 changes: 5 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if defined?(ChefSpec)
def create_s3_file(path)
ChefSpec::Matchers::ResourceMatcher.new(:s3_file, :create, path)
end
end
2 changes: 1 addition & 1 deletion libraries/s3_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'base64'

module S3FileLib
BLOCKSIZE_TO_READ = 1024 * 1000
BLOCKSIZE_TO_READ = 1024 * 1000 unless const_defined?(:BLOCKSIZE_TO_READ)
RestClient.proxy = ENV['http_proxy']

def self.build_headers(date, authorization, token)
Expand Down