Sha256: 34ae4763846d2d4ccddf32335dee739ed88887295a867a6a1acfa1ffbfbc6aa9

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

RENTJUICER_API_KEY = YAML.load_file(File.join(File.dirname(__FILE__), '/../rentjuicer_api_key.yml'))["api_key"]

def new_rentjuicer
  Rentjuicer::Client.new(RENTJUICER_API_KEY)
end

def mock_get(resource, response_fixture, params = {})
  url = "http://app.rentjuice.com/api/#{RENTJUICER_API_KEY}#{resource}"
  unless params.blank?
    stub_http_request(:get, url).with(:query => params).to_return(:body => mocked_response(response_fixture))
  else
    stub_http_request(:get, url).to_return(:body => mocked_response(response_fixture))
  end
end

def mocked_response(response_fixture)
  File.read(File.join(File.dirname(__FILE__), '/../responses', response_fixture))
end

def httparty_get(resource, response_fixture, params = {})
  url = "http://app.rentjuice.com/api/#{RENTJUICER_API_KEY}#{resource}"
  mock_get(resource, response_fixture, params)
  HTTParty.get url, :format => :json
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rentjuicer-0.3.0 spec/support/webmock_helper.rb
rentjuicer-0.2.1 spec/support/webmock_helper.rb
rentjuicer-0.2.0 spec/support/webmock_helper.rb