Sha256: 574bdfbd7f22c60ea01db6140acaa366e713c0079845692aa9162f55981418c7
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
# encoding: UTF-8 require 'rspec/expectations' RSpec::Matchers.define :have_created do |remote_file| match do |file_manager| if @expected_content downloaded_file = Tempfile.new('downloaded') downloaded_file.close subject.download(remote_file, downloaded_file.path) @actual_content = File.read(downloaded_file.path) downloaded_file.delete file_manager.exists?(remote_file) && \ @actual_content == @expected_content else file_manager.exists?(remote_file) end end chain :with_content do |expected_content| expected_content = File.read(expected_content) if File.file?(expected_content) @expected_content = expected_content end failure_message do if @expected_content <<-EOH Expected file '#{remote_file}' to exist with content: #{@expected_content} but instead got content: #{@actual_content} EOH else "Expected file '#{remote_file}' to exist" end end end RSpec::Matchers.define :contain_zip_entries do |zip_entries| match do |temp_zip_file| zip_entries = [zip_entries] if zip_entries.is_a? String zip_file = Zip::File.open(temp_zip_file.path) @missing_entries = [] zip_entries.each do |entry| @missing_entries << entry unless zip_file.find_entry(entry) end @missing_entries.empty? end failure_message do |temp_zip_file| "Expected #{temp_zip_file.path} to contain zip entries: #{@missing_entries}" end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
vagrant-cloudstack-1.1.0 | vendor/bundle/gems/winrm-fs-0.1.0/spec/matchers.rb |
winrm-fs-0.1.0 | spec/matchers.rb |