Sha256: f83321a1b01338aceb1d6ec414ece67a0ac92ae0dc55b63d3698a43bc56d9b86

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

module FakeWebHelper
  def fake(uri, options = {})
    verb = options[:verb] || :get
    FakeWeb.register_uri(verb, uri, response: response(options))
  end

  def response(options)
    header(options) + body(options)
  end

  def header(options)
    status = options[:status] || 200
    message = options[:message] || 'OK'
    location = options[:location] || ''
    "HTTP/1.1 #{status} #{message}\nLocation: #{location}\n\n"
  end

  def body(options)
    options[:file] ? File.read("spec/fixtures/#{options[:file]}") : ''
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picture_from-1.0.1 spec/support/fake_web_helper.rb
picture_from-1.0.0 spec/support/fake_web_helper.rb