Sha256: fd7fc0d1c2c871efee3c52cc782dc5e8f67abc7184d05894f92c7b4da10ff9d3

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

require 'simple_oauth'

module DockTest
  module Methods

    %w(get post put patch delete options head).each do |meth_name|
      define_method meth_name do |path, params = '', headers = {}, &block|

        context = RequestContext.new(verb: meth_name, path: path, params: params, headers: headers)

        if DockTest.skippy? && context.verb_has_side_effects
          skip('this test is skipped in order to avoid potential side effects.')
        end

        @last_request = context.http_request
        @last_response = context.execute

        puts context.curl_command if ENV['OUTPUT_CURL']

        yield @last_response if block_given?

        @last_response
      end

    end

    private

      def last_response
        @last_response
      end

      def last_response_json
        MultiJson.load last_response.body
      end

      def last_request
        @last_request
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dock_test-0.4.8 lib/dock_test/methods.rb