Sha256: d8796afa3f5d55e7affa1a7dd21e3b9ee1418e33a8e9a8b0e07803929be2f772

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

module Helpers

  def key
    # returns a key that will be different for each example, to avoid any
    # cross-example interactions
    RSpec.current_example.metadata[:full_description].gsub(/\+/,'plus').gsub(/\W/,'-') + "/filename"
  end

  def create_remote(body)
    @proxy.fog_directory.files.create(:key => key, :body => body)
  end

  def proxy_path
    @proxy.file(key).proxy_path
  end

  def create_proxy(body)
    path = proxy_path
    path.dirname.mkpath
    path.open("w") do |f|
      f.write(body)
    end
  end

  def remote_body
    @proxy.file(key).fog_model.andand.body
  end

  def remote_exist?
    @proxy.file(key).exist?
  end

  def with_rails_defined
    begin
      Kernel.const_set("Rails", Struct.new(:root).new(RAILS_ROOT_PATH))
      yield
    ensure
      Kernel.send :remove_const, "Rails"
    end
  end

  def should_log(arg)
    expect(@proxy.logger).to receive(:info).with(arg)
  end

  def should_not_log(arg)
    expect(@proxy.logger).not_to receive(:info).with(arg)
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defog-0.9.5 spec/support/helpers.rb
defog-0.9.4 spec/support/helpers.rb