-
Notifications
You must be signed in to change notification settings - Fork 315
Open
Description
First, thanks for the awesome gem! I'm trying to do some tests that rely on the GitHub API that's causing some issues. In particular the method to retrieve a users stars.
I've got a Sinatra app combined with webmock to reply instead of GitHub:
# frozen_string_literal: true
# source https://robots.thoughtbot.com/how-to-stub-external-services-in-tests
require 'sinatra/base'
class FakeGitHub < Sinatra::Base
get '/users/:user/starred' do
json_response 200, 'user_starred.json'
end
private
def json_response(response_code, file_name)
content_type :json
status response_code
File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
end
end
However, the results from calling github.activity.starring.starred user: username
isn't the same as against the real API. I iterate over the results, however the real API I can do this:
starred_repos = github.activity.starring.starred user: username
starred_repos.each do |starred_repo|
puts starred_repo.name
end
But when mocking it requires this (the repo is inside repo
for some reason):
starred_repos = github.activity.starring.starred user: username
starred_repos.each do |starred_repo|
puts starred_repo.repo.name
end
I'm using JSON pulled directly from the API so not sure what's wrong--hoping you could provide some insight if possible!
Metadata
Metadata
Assignees
Labels
No labels