Sha256: 0f387d58740a6ed07290312c99ecae4479ffe86c1602452677b620d7a9bea6bb

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'rubygems'
require 'bacon'

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
# require 'gjman'

Bacon.summary_on_exit

def trash_tmp_files
  ($trashable_tmp_files || []).select {|f| f.path }.map(&:unlink)
  $trashable_tmp_files = nil
end

def tmp_file(file_name)
  (($trashable_tmp_files ||= []) << Tempfile.new(file_name))[-1]
end

def equal_in_size_as(expected_file)
  lambda do |subject_file|
    subject_file_size = File.size(subject_file).to_f
    expected_file_size = File.size(expected_file).to_f
    ((subject_file_size - expected_file_size).abs / subject_file_size) < 0.0001
  end
end

def smaller_in_size_than(expected_file)
  lambda do |subject_file|
    subject_file_size = File.size(subject_file)
    expected_file_size = File.size(expected_file)
    (subject_file_size - expected_file_size) < 0
  end
end

def bigger_in_size_than(expected_file)
  lambda do |subject_file|
    subject_file_size = File.size(subject_file)
    expected_file_size = File.size(expected_file)
    (subject_file_size - expected_file_size) > 0
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gjman-0.1.0 spec/spec_helper.rb