Sha256: ab7e714b22b6b716356f42e47924d0ca1fd1f5f6f75c2760767616602b0fbaf6

Contents?: true

Size: 989 Bytes

Versions: 3

Compression:

Stored size: 989 Bytes

Contents

require 'fakeweb'

FakeWeb.allow_net_connect = false

def stub_file(stub)
  File.join(File.dirname(__FILE__), 'stubs', stub)
end

def fake_it_all
  FakeWeb.clean_registry
  #FakeWeb.register_uri :head, %r{http://(api.)|(www.)?nodester.com(/items)?}, :status => ["200", "OK"]
 
  {
    # GET URLs
    :get => {
      'http://nodester.com/status' => 'platform_get_status',
      'http://arthur:dent@api.nodester.com/apps' => 'get_apps',
      %r|http://arthur:dent@api.nodester.com/app/[a-zA-Z0-0]+| => 'get_app'
    },
    # POST URLs
    :post => {
      'http://nodester.com/coupon' => 'platform_post_coupon',
      'http://arthur:dent@api.nodester.com/app' => 'post_app',
      'http://arthur:dent@api.nodester.com/npm' => 'post_npm'        
    },
    # PUT URLs
    :put => {
    },
    # DELETE URLs
    :delete => {
    }
  }.each do |method, requests|
    requests.each do |url, response|
      FakeWeb.register_uri(method, url, :response => stub_file(response))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nodester-0.0.5 spec/fakeweb_helper.rb
nodester-0.0.3 spec/fakeweb_helper.rb
nodester-0.0.2 spec/fakeweb_helper.rb