Sha256: f7ecf5de96f790c7ad4e72223494b627c4848f4ed5184619f6e8673b7c5fe6ef
Contents?: true
Size: 1.45 KB
Versions: 11
Compression:
Stored size: 1.45 KB
Contents
module Heroku class API module Mock # stub DELETE /user/keys/:key Excon.stub(:expects => 200, :method => :delete, :path => %r{^/user/keys/([^/]+)}) do |params| request_params, mock_data = parse_stub_params(params) key, _ = request_params[:captures][:path] key = CGI.unescape(key).gsub('%2E', '.') if key_data = get_mock_key(mock_data, key) mock_data[:keys].delete(key_data) { :status => 200 } else { :body => "Key not found.", :status => 404 } end end # stub DELETE /user/keys Excon.stub(:expects => 200, :method => :delete, :path => %r{^/user/keys}) do |params| request_params, mock_data = parse_stub_params(params) mock_data[:keys] = [] { :status => 200} end # stub GET /user/keys Excon.stub(:expects => 200, :method => :get, :path => %r{^/user/keys}) do |params| request_params, mock_data = parse_stub_params(params) { :body => Heroku::API::OkJson.encode(mock_data[:keys]), :status => 200 } end # stub POST /user/keys Excon.stub(:expects => 200, :method => :post, :path => %r{^/user/keys}) do |params| request_params, mock_data = parse_stub_params(params) mock_data[:keys] |= [{ 'email' => 'email@example.com', 'contents' => request_params[:body] }] { :status => 200 } end end end end
Version data entries
11 entries across 11 versions & 1 rubygems