Sha256: e83a0d57ab44d34275eef334b40148eb5f79aa6d1f54b4f8867224b9e37f2496

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

class FakeGemcutter
  def initialize(api_key)
    @api_key = api_key
  end

  def respond(code, text)
    [code, {"Content-Type" => "text/plain"}, text]
  end

  def call(env)
    request = Rack::Request.new(env)

    if request.env["HTTP_AUTHORIZATION"] != @api_key
      respond 401, "One cannot simply walk into Mordor!"
    elsif request.path == "/api/v1/gems" && request.post?
      respond 200, "Successfully registered rake (0.8.7)"
    elsif request.path == "/api/v1/gems/rake/owners"
      if request.post?
        respond 200, "Owner added successfully."
      elsif request.delete?
        respond 200, "Owner removed successfully."
      end
    elsif request.path == "/api/v1/gems/rake/owners.yaml" && request.get?
      yaml = YAML.dump([{'email' => 'geddy@example.com'},
                        {'email' => 'lerxst@example.com'}])
      respond(200, yaml)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spade-0.0.1 spec/support/fake_gemcutter.rb