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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"

group :test do
gem "fastimage", "~> 2.1.0"
gem "minitest", "~> 5.10.3"
gem "rake"
gem "rubocop", "~> 0.50.0"
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.3.0)
fastimage (2.1.0)
minitest (5.10.3)
parallel (1.12.0)
parser (2.4.0.0)
Expand All @@ -25,10 +26,11 @@ PLATFORMS
ruby

DEPENDENCIES
fastimage (~> 2.1.0)
minitest (~> 5.10.3)
rake
rubocop (~> 0.50.0)
safe_yaml (~> 1.0.4)

BUNDLED WITH
1.15.3
1.15.4
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

<img src="https://user-images.githubusercontent.com/1840802/31236555-436777c4-a9a9-11e7-8377-c5c4c4c7722e.png" width="650" />

There are some lint tests in place to ensure each topic is formatted in the way we expect. Travis
CI will run the tests automatically. If you want to run the tests yourself locally, you will need
Ruby and Bundler installed.

You can run the tests using:

```bash
script/cibuild
```

Topic pages, curated by the community.

[Topics](https://help.github.com/articles/about-topics/) help you explore repositories in a particular subject area, learn more about a subject area, and find projects to contribute to.
Expand Down
6 changes: 4 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require "minitest/autorun"
require "fastimage"
require "yaml"

IMAGE_EXTENSIONS = %w[.jpg .jpeg .png].freeze

IMAGE_WIDTH = 288
IMAGE_HEIGHT = 288
MAX_IMAGE_FILESIZE_IN_BYTES = 65_000
VALID_METADATA_KEYS = %w[aliases created_by display_name github_url logo related
released short_description topic url wikipedia_url].freeze

REQUIRED_METADATA_KEYS = %w[topic short_description].freeze

MAX_TOPIC_LENGTH = 35
Expand Down
14 changes: 13 additions & 1 deletion test/topics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,26 @@
assert File.file?(path), "expected #{path} to be a file"
end

it "has only one image with the right name" do
it "has at most one image with the right name, type, and dimensions" do
paths = image_paths_for(topic)

assert paths.size <= 1, "expected at most one image, found #{paths.size}"

if path = paths.first
assert_equal topic, File.basename(path, File.extname(path)),
"expected image to be named [topic].[extension]"

width, height = FastImage.size(path)
assert_equal IMAGE_WIDTH, width, "topic images should be #{IMAGE_WIDTH}px wide"
assert_equal IMAGE_HEIGHT, height, "topic images should be #{IMAGE_HEIGHT}px tall"

assert_includes IMAGE_EXTENSIONS, ".#{FastImage.type(path)}",
"topic images should be one of #{IMAGE_EXTENSIONS.join(', ')}"

file_size = FastImage.new(path).content_length
assert file_size <= MAX_IMAGE_FILESIZE_IN_BYTES,
"topic images should not exceed #{MAX_IMAGE_FILESIZE_IN_BYTES} bytes, got " \
"#{file_size} bytes"
end
end

Expand Down
Binary file modified topics/bitcoin/bitcoin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topics/elixir/elixir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topics/sketch/sketch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.