Skip to content

Instantly share code, notes, and snippets.

@nevernormal1
Created March 26, 2010 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevernormal1/345253 to your computer and use it in GitHub Desktop.
Save nevernormal1/345253 to your computer and use it in GitHub Desktop.
# Load the adwords hierarchy, because the gem doesn't
module AdWords
module V13
module TrafficEstimatorService
class KeywordRequest
end
end
end
end
Given /^generic keyword traffic estimates$/ do
request = mock('request')
AdWords::V13::TrafficEstimatorService::KeywordRequest.stub(:new).and_return(request)
response = mock('response')
response.stub(:lowerCpc).and_return(1.5 * 1e6)
response.stub(:lowerClicksPerDay).and_return(1000)
adwords = AdWords::API.stub(:new).and_return(mock('adwords', :get_service => service = mock('adword service', :estimateKeywordList => [response])))
end
Given /^the following keyword traffic estimates:$/ do |table|
requests = []
responses = []
table.hashes.each do |row|
mock('request').tap do |request|
AdWords::V13::TrafficEstimatorService::KeywordRequest.stub(:new).with(nil, 100000000, false, row['Keyword'], "Broad").and_return(request)
requests << request
end
mock('response').tap do |response|
response.stub(:lowerCpc).and_return(row['Lower Cpc'].to_f * 1e6)
response.stub(:lowerClicksPerDay).and_return(row['Lower Clicks'].to_i)
responses << response
end
end
adwords = AdWords::API.stub(:new).and_return(mock('adwords', :get_service => service = mock('adword service')))
service.stub(:estimateKeywordList).with(requests).and_return(responses)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment