Sha256: 8e2613a626f7ae69c084d018af74f410f3f4940f0ebbd1a29c2daa605076f1eb

Contents?: true

Size: 1.5 KB

Versions: 23

Compression:

Stored size: 1.5 KB

Contents

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|
    msg = "Expected #{temp_zip_file.path} to contain zip entries: #{@missing_entries}\n Got: "
    @zip_file.each do |entry|
      msg << entry.name << ', '
    end
    msg
  end
end

Version data entries

23 entries across 16 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/matchers.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.0/spec/matchers.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.0/spec/matchers.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/matchers.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.0/spec/matchers.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/matchers.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/matchers.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.0/spec/matchers.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.0/spec/matchers.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.1/spec/matchers.rb
winrm-fs-1.3.1 spec/matchers.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.3.0/spec/matchers.rb
winrm-fs-1.3.0 spec/matchers.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/winrm-fs-1.2.1/spec/matchers.rb
winrm-fs-1.2.1 spec/matchers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.2.0/spec/matchers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/winrm-fs-1.2.0/spec/matchers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.2.0/spec/matchers.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.2.0/spec/matchers.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/winrm-fs-1.2.0/spec/matchers.rb