Sha256: e6df159a50289e202994152d51e8ac1ec813f5876f39cf559b2dd9037f2318e9

Contents?: true

Size: 987 Bytes

Versions: 10

Compression:

Stored size: 987 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.file(key).fog_model.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)
    @proxy.logger.should_receive(:info).with(arg)
  end

  def should_not_log(arg)
    @proxy.logger.should_not_receive(:info).with(arg)
  end


end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
defog-0.9.3 spec/support/helpers.rb
defog-0.9.2 spec/support/helpers.rb
defog-0.9.1 spec/support/helpers.rb
defog-0.9.0 spec/support/helpers.rb
defog-0.8.0 spec/support/helpers.rb
defog-0.7.2 spec/support/helpers.rb
defog-0.7.1 spec/support/helpers.rb
defog-0.7.0 spec/support/helpers.rb
defog-0.6.1 spec/support/helpers.rb
defog-0.6.0 spec/support/helpers.rb