Sha256: acc3c12d20c90a44a5cdd0d7773b4ef2d45f29755c23ed7a398731c0b38accd1

Contents?: true

Size: 844 Bytes

Versions: 7

Compression:

Stored size: 844 Bytes

Contents

module Helpers

  def key
    # returns a key that will be different for each example, to avoid any
    # cross-example interactions
    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.fog_directory.files.get(key).body
  end

  def remote_exist?
    !!@proxy.fog_directory.files.head(key)
  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

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
defog-0.4.0 spec/support/helpers.rb
defog-0.3.2 spec/support/helpers.rb
defog-0.3.1 spec/support/helpers.rb
defog-0.3.0 spec/support/helpers.rb
defog-0.2.0 spec/support/helpers.rb
defog-0.1.1 spec/support/helpers.rb
defog-0.1.0 spec/support/helpers.rb