Sha256: ccf719ded88bbaa1e53506aa0e206112da732a4de4332dd839bfa582e178d1f2

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 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'      
    },
    # 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

1 entries across 1 versions & 1 rubygems

Version Path
nodester-0.0.1 spec/fakeweb_helper.rb