Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/octokit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ def client_secret=(value)
@client_secret = value
end

# Wrapper around Kernel#warn to print warnings unless
# OCTOKIT_SILENT is set to true.
#
# @return [nil]
def octokit_warn(*message)
unless ENV['OCTOKIT_SILENT']
warn message
end
end

private

def reset_agent
Expand Down Expand Up @@ -364,15 +374,5 @@ def parse_query_and_convenience_headers(options)

opts
end

# Wrapper around Kernel#warn to print warnings unless
# OCTOKIT_SILENT is set to true.
#
# @return [nil]
def octokit_warn(*message)
unless ENV['OCTOKIT_SILENT']
warn message
end
end
end
end
28 changes: 28 additions & 0 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,34 @@
c.define_cassette_placeholder("<GITHUB_TEST_ORG_TEAM_ID>") do
"10050505050000"
end

c.before_http_request(:real?) do |request|
next if request.headers['X-Vcr-Test-Repo-Setup']
next unless request.uri.include? test_github_repository

options = {
:headers => {'X-Vcr-Test-Repo-Setup' => 'true'},
:auto_init => true
}

test_repo = "#{test_github_login}/#{test_github_repository}"
if !oauth_client.repository?(test_repo, options)
Octokit.octokit_warn "NOTICE: Creating #{test_repo} test repository."
oauth_client.create_repository(test_github_repository, options)
end

test_org_repo = "#{test_github_org}/#{test_github_repository}"
if !oauth_client.repository?(test_org_repo, options)
Octokit.octokit_warn "NOTICE: Creating #{test_org_repo} test repository."
options[:organization] = test_github_org
oauth_client.create_repository(test_github_repository, options)
end
end

c.ignore_request do |request|
!!request.headers['X-Vcr-Test-Repo-Setup']
end

c.default_cassette_options = {
:serialize_with => :json,
# TODO: Track down UTF-8 issue and remove
Expand Down