Skip to content

Commit

Permalink
Fix all Rubocop warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Oct 3, 2017
1 parent 7ce5077 commit a9d13ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Rake::TestTask.new do |t|
t.verbose = false
end

task :default => :test
task default: :test
12 changes: 6 additions & 6 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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__))
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions test/topics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

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

Expand All @@ -38,7 +38,7 @@
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")
Expand All @@ -50,14 +50,16 @@
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
Expand Down

0 comments on commit a9d13ec

Please sign in to comment.