Module: MockRequests

Defined in:
lib/run_keeper/mock_requests.rb

Instance Method Summary collapse

Instance Method Details

#stub_successful_runkeeper_fitness_activities_requestObject



2
3
4
5
6
# File 'lib/run_keeper/mock_requests.rb', line 2

def stub_successful_runkeeper_fitness_activities_request
  stub_successful_runkeeper_user_request
  stub_successful_runkeeper_fitness_activities_page_2_request
  stub_runkeeper_fitness_activities_request.to_return :status => 200, :body => {"size" => "4", "items" => [{"type" => "Running", "start_time" => "Thu, 25 Aug 2011 17:41:28", "total_distance" => "5492.22273600001", "duration" => "1743.946", "uri" => "/activities/39"}, {"type" => "Running", "start_time" => "Thu, 1 Sep 2011 17:41:28", "total_distance" => "5492.22273600001", "duration" => "1743.946", "uri" => "/activities/40"}, {"type" => "Running", "start_time" => "Fri, 2 Sep 2011 17:41:28", "total_distance" => "5492.22273600001", "duration" => "2090.123", "uri" => "/activities/41"}, {"type" => "Running", "start_time" => "Wed, 7 Sep 2011 17:41:28", "total_distance" => "5492.22273600001", "duration" => "1743.946", "uri" => "/activities/42"}], "next" => "/fitnessActivities?page=1"}, :headers => {"content-type" => "application/vnd.com.runkeeper.FitnessActivityFeed+json;charset=ISO-8859-1"}
end

#stub_successful_runkeeper_profile_requestObject



8
9
10
11
# File 'lib/run_keeper/mock_requests.rb', line 8

def stub_successful_runkeeper_profile_request
  stub_successful_runkeeper_user_request
  stub_runkeeper_profile_request.to_return :status => 200, :body => {"name" => "John Doe", "location" => "Anytown, USA", "athlete_type" => "Runner", "goal" => "To get off the couch", "gender" => "M", "birthday" => "Sat, Jan 1 2011 00:00:00", "elite" => "true", "profile" => "http://www.runkeeper.com/user/JohnDoe", "small_picture" => "http://www.runkeeper.com/user/JohnDoe/small.jpg", "normal_picture" => "http://www.runkeeper.com/user/JohnDoe/normal.jpg", "medium_picture" => "http://www.runkeeper.com/user/JohnDoe/medium.jpg", "large_picture" => "http://www.runkeeper.com/user/JohnDoe/large.jpg"}, :headers => {"content-type" => "application/vnd.com.runkeeper.profile+json;charset=ISO-8859-1"}
end

#stub_successful_runkeeper_token_requestObject



13
14
15
# File 'lib/run_keeper/mock_requests.rb', line 13

def stub_successful_runkeeper_token_request
  stub_runkeeper_token_request.to_return :status => 200, :body => {'access_token' => 'my_token', 'token_type' => 'Bearer'}, :headers => {"content-type" => "application/json;charset=ISO-8859-1"}
end

#stub_successful_runkeeper_user_requestObject



17
18
19
# File 'lib/run_keeper/mock_requests.rb', line 17

def stub_successful_runkeeper_user_request
  stub_runkeeper_user_request.to_return :status => 200, :body => {"userID" => /\d+/, "profile" => "/profile", "settings" => "/settings", "fitness_activities" => "/fitnessActivities", "background_activities" => "/backgroundActivities", "sleep" => "/sleep", "nutrition" => "/nutrition", "weight" => "/weight", "general_measurements" => "/generalMeasurements", "diabetes" => "/diabetes", "records" => "/records", "team" => "/team", "strength_training_activities" => "/strengthTrainingActivities"}, :headers => {'content-type' => 'application/vnd.com.runkeeper.user+json;charset=ISO-8859-1'}
end

#stub_unsuccessful_runkeeper_profile_requestObject



21
22
23
24
# File 'lib/run_keeper/mock_requests.rb', line 21

def stub_unsuccessful_runkeeper_profile_request
  stub_successful_runkeeper_user_request
  stub_runkeeper_profile_request.to_return :status => 500, :body => {}, :headers => {}
end

#stub_unsuccessful_runkeeper_token_requestObject



26
27
28
# File 'lib/run_keeper/mock_requests.rb', line 26

def stub_unsuccessful_runkeeper_token_request
  stub_runkeeper_token_request.to_return :status => 500, :body => {}, :headers => {}
end

#stub_unsuccessful_runkeeper_user_requestObject



30
31
32
# File 'lib/run_keeper/mock_requests.rb', line 30

def stub_unsuccessful_runkeeper_user_request
  stub_runkeeper_user_request.to_return :status => 500, :body => {}, :headers => {}
end