Sha256: a905a4d58734a5d0960d26bbf8ec4ed74f3285ff92ec3a96f48cef4f73e47773
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
require "pry" require "refile" require "refile/backend_examples" tmp_path = Dir.mktmpdir at_exit do FileUtils.remove_entry_secure(tmp_path) end Refile.store = Refile::Backend::FileSystem.new(File.expand_path("default_store", tmp_path)) Refile.cache = Refile::Backend::FileSystem.new(File.expand_path("default_cache", tmp_path)) class FakePresignBackend < Refile::Backend::FileSystem Signature = Struct.new(:as, :id, :url, :fields) def presign id = Refile::RandomHasher.new.hash Signature.new("file", id, "/presigned/posts/upload", { token: "xyz123", id: id }) end end Refile.backends["limited_cache"] = FakePresignBackend.new(File.expand_path("default_cache", tmp_path), max_size: 100) Refile.direct_upload = ["cache", "limited_cache"] Refile.processor(:reverse) do |file| StringIO.new(file.read.reverse) end Refile.processor(:upcase, proc { |file| StringIO.new(file.read.upcase) }) Refile.processor(:concat) do |file, *words| content = File.read(file.download.path) tempfile = Tempfile.new("concat") tempfile.write(content) words.each do |word| tempfile.write(word) end tempfile.close File.open(tempfile.path, "r") end Refile.processor(:convert_case) do |file, format:| case format when "up" then StringIO.new(file.read.upcase) when "down" then StringIO.new(file.read.downcase) else file end end class Refile::FileDouble def initialize(data) @io = StringIO.new(data) end def read(*args) @io.read(*args) end def size @io.size end def eof? @io.eof? end def close @io.close end end module PathHelper def path(filename) File.expand_path(File.join("fixtures", filename), File.dirname(__FILE__)) end end RSpec.configure do |config| config.include PathHelper end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
refile-0.2.4 | spec/refile/spec_helper.rb |
refile-0.2.3 | spec/refile/spec_helper.rb |