Sha256: 2e31c81ac821011bd3b3c19764d734a0880dba400a09d825063507559afa7586

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

require "tempfile"

module Helpers
  def image_path(type = :default)
    if type != :without_extension
      File.join("spec/fixtures",
        case type
        when :default, :jpg   then "default.jpg"
        when :animation, :gif then "animation.gif"
        when :pdf             then "document.pdf"
        when :psd             then "image.psd"
        when :exif            then "exif.jpg"
        when :not             then "not_an_image.rb"
        else
          fail "image #{type.inspect} doesn't exist"
        end
      )
    else
      path = random_path
      FileUtils.cp image_path, path
      path
    end
  end

  def image_url
    "https://avatars2.githubusercontent.com/u/795488?v=2&s=40"
  end

  def random_path(basename = "")
    @tempfile = Tempfile.open(basename)
    @tempfile.path
  end
end

RSpec.configure do |config|
  config.include Helpers
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mini_magick-4.0.0 spec/support/helpers.rb
mini_magick-4.0.0.rc spec/support/helpers.rb