Sha256: 68044e7aea915c10bcec7e3ba121495e069d3cfc239bd01a997a5bb360a64f1f

Contents?: true

Size: 547 Bytes

Versions: 2

Compression:

Stored size: 547 Bytes

Contents

module LazyResource
  class HttpMock
    class Responder
      [:post, :put, :get, :delete].each do |method|
        module_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{method}(path, body='', status=200, response_headers={})
            Typhoeus.stub(path, :method => :#{method}).and_return(Typhoeus::Response.new(:code => status, :headers => response_headers, :body => body, :time => 0.3))
          end
        RUBY
      end
    end

    class << self
      def respond_to(*args)
        yield Responder.new
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lazy_resource-0.5.0 lib/lazy_resource/http_mock.rb
lazy_resource-0.4.0 lib/lazy_resource/http_mock.rb