Sha256: 2947e44db066451c238c6756bb04be8a22695620224c5191b6224234639d0c8c

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

module Heroku
  class API
    module Mock

      # stub DELETE /apps/:app/config_vars/:key
      Excon.stub(:expects => 200, :method => :delete, :path => %r{^/apps/([^/]+)/config_vars/([^/]+)$}) do |params|
        request_params, mock_data = parse_stub_params(params)
        app, key, _ = request_params[:captures][:path]
        with_mock_app(mock_data, app) do
          mock_data[:config_vars][app].delete(key)
          {
            :body   => Heroku::API::OkJson.encode(mock_data[:config_vars][app]),
            :status => 200
          }
        end
      end

      # stub GET /apps/:app/config_vars
      Excon.stub(:expects => 200, :method => :get, :path => %r{^/apps/([^/]+)/config_vars$}) do |params|
        request_params, mock_data = parse_stub_params(params)
        app, _ = request_params[:captures][:path]
        with_mock_app(mock_data, app) do
          {
            :body   => Heroku::API::OkJson.encode(mock_data[:config_vars][app]),
            :status => 200
          }
        end
      end

      # stub PUT /apps/:app/config_vars
      Excon.stub(:expects => 200, :method => :put, :path => %r{^/apps/([^/]+)/config_vars$}) do |params|
        request_params, mock_data = parse_stub_params(params)
        app, _ = request_params[:captures][:path]
        with_mock_app(mock_data, app) do
          new_config_vars = request_params[:body]
          mock_data[:config_vars][app].merge!(new_config_vars)
          {
            :body   => Heroku::API::OkJson.encode(mock_data[:config_vars][app]),
            :status => 200
          }
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
heroku-api-0.1.7 lib/heroku/api/mock/config_vars.rb
heroku-api-0.1.6 lib/heroku/api/mock/config_vars.rb
heroku-api-0.1.5 lib/heroku/api/mock/config_vars.rb
heroku-api-0.1.4 lib/heroku/api/mock/config_vars.rb
heroku-api-0.1.3 lib/heroku/api/mock/config_vars.rb
heroku-api-0.1.2 lib/heroku/api/mock/config_vars.rb
heroku-api-0.1.0 lib/heroku/api/mock/config_vars.rb