Sha256: 714829b8989919426f4d1e8ce8dafa7840aecad4b6ebab39410c1ddf7a56224d

Contents?: true

Size: 960 Bytes

Versions: 11

Compression:

Stored size: 960 Bytes

Contents

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

def new_ygl
  YouGotListed::Client.new(YGL_API_KEY)
end

def new_ygl_timeout_5
  YouGotListed::Client.new(YGL_API_KEY, 5)
end

def mock_get(base_uri, method, response_fixture, params = {})
  url = base_uri + method
  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__), '/../fixtures/responses', "#{response_fixture}"))
end

def httparty_get(base_uri, method, response_fixture, params = {})
  mock_get(base_uri, method, response_fixture, params)
  url = base_uri + method
  VCR.use_cassette(method.gsub('/', '_')) do
    HTTParty.get url, :format => :xml, :query => params
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
you_got_listed-0.7.2 spec/support/webmock_helper.rb
you_got_listed-0.7.1 spec/support/webmock_helper.rb
you_got_listed-0.7.0 spec/support/webmock_helper.rb
you_got_listed-0.6.6 spec/support/webmock_helper.rb
you_got_listed-0.6.5 spec/support/webmock_helper.rb
you_got_listed-0.6.4 spec/support/webmock_helper.rb
you_got_listed-0.6.3 spec/support/webmock_helper.rb
you_got_listed-0.6.2 spec/support/webmock_helper.rb
you_got_listed-0.6.1 spec/support/webmock_helper.rb
you_got_listed-0.6.0 spec/support/webmock_helper.rb
you_got_listed-0.5.1 spec/support/webmock_helper.rb