This commit is contained in:
Tal Safran 2018-03-06 17:44:12 -08:00
Родитель 41e4961136
Коммит ef6c88792b
4 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -3,6 +3,7 @@ source "https://rubygems.org"
group :test do
gem "fastimage", "~> 2.1.0"
gem "minitest", "~> 5.10.3"
gem "octokit", "~> 4.0"
gem "rake"
gem "rubocop", "~> 0.50.0"
gem "safe_yaml", "~> 1.0.4"

Просмотреть файл

@ -1,13 +1,21 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.3.0)
faraday (0.14.0)
multipart-post (>= 1.2, < 3)
fastimage (2.1.0)
minitest (5.10.3)
multipart-post (2.0.0)
octokit (4.8.0)
sawyer (~> 0.8.0, >= 0.5.3)
parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
powerpack (0.1.1)
public_suffix (3.0.2)
rainbow (2.2.2)
rake
rake (12.0.0)
@ -20,6 +28,9 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
safe_yaml (1.0.4)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
unicode-display_width (1.3.0)
PLATFORMS
@ -28,6 +39,7 @@ PLATFORMS
DEPENDENCIES
fastimage (~> 2.1.0)
minitest (~> 5.10.3)
octokit (~> 4.0)
rake
rubocop (~> 0.50.0)
safe_yaml (~> 1.0.4)

Просмотреть файл

@ -33,25 +33,35 @@ describe "collections" do
end
it "does not include items pointing to private or non-existent repos" do
invalid_repos = []
items_for_collection(collection).each do |item|
next unless item.match?(USERNAME_AND_REPO_REGEX)
repo_url = URI("https://api.github.com/repos/#{item}")
response = Net::HTTP.get_response(repo_url)
begin
Octokit.repo(item)
rescue Octokit::NotFound
invalid_repos << item
end
assert response.code == 200, "repository #{item} does not exist or is private"
assert_empty invalid_repos, "repositories #{item} do not exist or are private"
end
end
it "does not include items pointing to non-existent users or organizations" do
invalid_users = []
items_for_collection(collection).each do |item|
next unless item.match?(USERNAME_REGEX)
user_url = URI("https://api.github.com/users/#{item}")
response = Net::HTTP.get_response(user_url)
assert response.code == 200, "user or organization #{item} does not exist"
begin
Octokit.user(item)
rescue Octokit::NotFound
invalid_users << item
end
end
assert_empty invalid_users, "users or organizations #{invalid_users} do not exist"
end
it "has an index.md" do

Просмотреть файл

@ -1,6 +1,7 @@
# rubocop:disable Metrics/LineLength
require_relative "./test_helper"
require "octokit"
VALID_COLLECTION_METADATA_KEYS = %w[collection created_by display_name image items].freeze
REQUIRED_COLLECTION_METADATA_KEYS = %w[items display_name].freeze