зеркало из https://github.com/github/explore.git
Fix all Rubocop warnings.
This commit is contained in:
Родитель
7ce5077100
Коммит
a9d13ec137
2
Rakefile
2
Rakefile
|
@ -7,4 +7,4 @@ Rake::TestTask.new do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
task default: :test
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
require "minitest/autorun"
|
||||
require "yaml"
|
||||
|
||||
IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png"].freeze
|
||||
IMAGE_EXTENSIONS = %w[.jpg .jpeg .png].freeze
|
||||
|
||||
VALID_METADATA_KEYS = ["aliases", "created_by", "display_name", "github_url", "logo", "related",
|
||||
"released", "short_description", "topic", "url", "wikipedia_url"].freeze
|
||||
VALID_METADATA_KEYS = %w[aliases created_by display_name github_url logo related
|
||||
released short_description topic url wikipedia_url].freeze
|
||||
|
||||
REQUIRED_METADATA_KEYS = ["topic", "short_description"].freeze
|
||||
REQUIRED_METADATA_KEYS = %w[topic short_description].freeze
|
||||
|
||||
def topics_dir
|
||||
File.expand_path("../topics", File.dirname(__FILE__))
|
||||
|
@ -39,8 +39,8 @@ def metadata_for(topic)
|
|||
parts = File.read(path).split("---", 3)
|
||||
return unless parts.size >= 2
|
||||
|
||||
metadata = begin
|
||||
YAML.load(parts[1])
|
||||
begin
|
||||
YAML.safe_load(parts[1])
|
||||
rescue Psych::SyntaxError => ex
|
||||
flunk "invalid YAML: #{ex.message}"
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe "topics" do
|
|||
|
||||
if path = paths.first
|
||||
assert_equal topic, File.basename(path, File.extname(path)),
|
||||
"expected image to be named [topic].[extension]"
|
||||
"expected image to be named [topic].[extension]"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ describe "topics" do
|
|||
if File.file?(path)
|
||||
lines = File.readlines(path)
|
||||
|
||||
assert lines.size > 0
|
||||
assert !lines.empty?
|
||||
assert_equal "---\n", lines[0], "expected file to start with Jekyll front matter ---"
|
||||
|
||||
end_index = lines.slice(1..-1).index("---\n")
|
||||
|
@ -50,14 +50,16 @@ describe "topics" do
|
|||
metadata = metadata_for(topic)
|
||||
refute_empty metadata, "expected some metadata for topic"
|
||||
|
||||
metadata.each do |key, value|
|
||||
metadata.each_key do |key,|
|
||||
assert_includes VALID_METADATA_KEYS, key, "unexpected metadata key '#{key}'"
|
||||
end
|
||||
|
||||
REQUIRED_METADATA_KEYS.each do |key|
|
||||
assert metadata.key?(key), "expected to have '#{key}' defined for topic"
|
||||
assert metadata[key] && metadata[key].strip.size > 0,
|
||||
"expected to have a value for '#{key}'"
|
||||
assert metadata[key]&.strip&.size&.positive?,
|
||||
"expected to have a value for '#{key}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче