Skip to content

Commit 9661e66

Browse files
authored
Add a test suite through RSpec (#1)
1 parent 51ef1db commit 9661e66

File tree

23 files changed

+506
-72
lines changed

23 files changed

+506
-72
lines changed

.gemspec

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
require_relative "lib/jekyll-transcode-image-filters/version"
1+
# frozen_string_literal: true
22

3-
Gem::Specification.new do |s|
4-
s.name = 'jekyll-transcode-image-filters'
5-
s.version = Jekyll::TranscodeImageFilters::VERSION
6-
s.date = '2024-12-31'
7-
s.summary = 'Adds liquid filters to create responsive images and transcode them to browser-friendly formats.'
8-
s.description = 'Adds the liquid filters `jpg` and `webp` to create responsive images and transcode them to browser-friendly formats. An optional parameter is available to also resize the image, as an example: `{{ imagePath | webp: "480x270" }}`'
9-
s.authors = ['Willem \'Jip\' Wijnia']
10-
s.files = Dir["lib/**/*"]
11-
s.homepage = 'https://github.com/Garanas/jekyll-transcode-image-filters'
12-
s.license = 'MIT'
3+
require_relative 'lib/jekyll_transcode_image_filters/version'
134

14-
s.required_ruby_version = ">= 3.0.0"
5+
Gem::Specification.new do |spec|
6+
spec.name = 'jekyll-transcode-image-filters'
7+
spec.version = Jekyll::TranscodeImageFilters::VERSION
8+
spec.summary = <<~SUMMARY
9+
Adds liquid filters to create responsive images and transcode them to browser-friendly formatspec.
10+
SUMMARY
1511

16-
s.add_dependency 'jekyll', '> 3.3', '< 5.0'
17-
s.add_dependency 'mini_magick', '~> 4.8'
12+
spec.description = <<~DESCRIPTION
13+
Adds the liquid filters `jpg` and `webp` to create responsive images and transcode them to browser-friendly formatspec.
14+
An optional parameter is available to also resize the image, as an example:
15+
`{{ imagePath | webp: "480x270" }}`
16+
DESCRIPTION
17+
spec.authors = ["Willem 'Jip' Wijnia"]
18+
spec.files = Dir['lib/**/*']
19+
spec.homepage = 'https://github.com/Garanas/jekyll-transcode-image-filters'
20+
spec.license = 'MIT'
21+
22+
spec.required_ruby_version = '>= 2.5.0'
23+
24+
spec.add_dependency 'jekyll', '> 3.3', '< 5.0'
25+
spec.add_dependency 'mini_magick', '~> 4.8'
26+
27+
spec.add_development_dependency 'bundler'
28+
spec.add_development_dependency 'nokogiri', '~> 1.6'
29+
spec.add_development_dependency 'rake', '~> 13.0'
30+
spec.add_development_dependency 'rspec', '~> 3.0'
31+
spec.add_development_dependency 'rubocop'
32+
spec.add_development_dependency 'rubocop-jekyll', '~> 0.12.0'
33+
spec.add_development_dependency 'typhoeus', '>= 0.7', '< 2.0'
1834
end

.github/workflows/build.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Build
22

33
on:
4+
workflow_call:
5+
workflow_dispatch:
46
push:
57
branches: ["main"]
68
pull_request:
@@ -10,6 +12,8 @@ permissions:
1012
contents: read
1113

1214
jobs:
15+
test:
16+
uses: ./.github/workflows/ci.yaml
1317
build:
1418
runs-on: ubuntu-latest
1519
strategy:
@@ -26,8 +30,9 @@ jobs:
2630
with:
2731
ruby-version: ${{ matrix.ruby-version }}
2832
bundler-cache: true
29-
- name: Run tests
30-
run: rake build
33+
34+
- name: Build gem
35+
run: rake test
3136

3237
# https://github.com/actions/upload-artifact
3338
- name: Upload artifacts

.github/workflows/ci.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Continuous Integration
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
push:
7+
branches: ["main"]
8+
pull_request:
9+
branches: ["main"]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
ruby-version: ["3.2"]
20+
21+
steps:
22+
# https://github.com/actions/checkout
23+
- uses: actions/checkout@v4
24+
25+
# https://github.com/ruby/setup-ruby
26+
- name: Set up Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby-version }}
30+
bundler-cache: true
31+
32+
# - name: Run linter
33+
# run: |
34+
# bundle exec rubocop
35+
36+
- name: Run tests
37+
run: rake test

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
inherit_from: .rubocop_todo.yml
2+
3+
Metrics/MethodLength:
4+
Max: 20
5+
6+
AllCops:
7+
Exclude:
8+
- 'spec/**/*'

.rubocop_todo.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2025-03-03 07:37:46 UTC using RuboCop version 1.18.4.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 2
10+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
11+
# IgnoredMethods: refine
12+
Metrics/BlockLength:
13+
Max: 97
14+
15+
# Offense count: 1
16+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
17+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
18+
Naming/FileName:
19+
Exclude:
20+
- 'spec/transcode-image-filters_spec.rb'
21+
22+
# Offense count: 1
23+
# Configuration parameters: AllowedConstants.
24+
Style/Documentation:
25+
Exclude:
26+
- 'spec/**/*'
27+
- 'test/**/*'

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
24

35
gemspec
46

5-
gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"]
7+
gem 'jekyll', ENV['JEKYLL_VERSION'] if ENV['JEKYLL_VERSION']

Gemfile.lock

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
jekyll-transcode-image-filters (0.0.1)
4+
jekyll-transcode-image-filters (0.0.2)
55
jekyll (> 3.3, < 5.0)
66
mini_magick (~> 4.8)
77

@@ -10,18 +10,26 @@ GEM
1010
specs:
1111
addressable (2.8.7)
1212
public_suffix (>= 2.0.2, < 7.0)
13+
ast (2.4.2)
1314
bigdecimal (3.1.9)
1415
colorator (1.1.0)
1516
concurrent-ruby (1.3.4)
17+
diff-lcs (1.6.0)
1618
em-websocket (0.5.3)
1719
eventmachine (>= 0.12.9)
1820
http_parser.rb (~> 0)
21+
ethon (0.16.0)
22+
ffi (>= 1.15.0)
1923
eventmachine (1.2.7)
2024
ffi (1.17.1-x64-mingw-ucrt)
25+
ffi (1.17.1-x86_64-linux-gnu)
2126
forwardable-extended (2.6.0)
2227
google-protobuf (4.29.2-x64-mingw-ucrt)
2328
bigdecimal
2429
rake (>= 13)
30+
google-protobuf (4.29.2-x86_64-linux)
31+
bigdecimal
32+
rake (>= 13)
2533
http_parser.rb (0.8.0)
2634
i18n (1.14.6)
2735
concurrent-ruby (~> 1.0)
@@ -55,20 +63,66 @@ GEM
5563
rb-inotify (~> 0.9, >= 0.9.10)
5664
mercenary (0.4.0)
5765
mini_magick (4.13.2)
66+
nokogiri (1.18.3-x64-mingw-ucrt)
67+
racc (~> 1.4)
68+
nokogiri (1.18.3-x86_64-linux-gnu)
69+
racc (~> 1.4)
70+
parallel (1.26.3)
71+
parser (3.3.7.1)
72+
ast (~> 2.4.1)
73+
racc
5874
pathutil (0.16.2)
5975
forwardable-extended (~> 2.6)
6076
public_suffix (6.0.1)
77+
racc (1.8.1)
78+
rainbow (3.1.1)
6179
rake (13.2.1)
6280
rb-fsevent (0.11.2)
6381
rb-inotify (0.11.1)
6482
ffi (~> 1.0)
83+
regexp_parser (2.10.0)
6584
rexml (3.4.0)
6685
rouge (4.5.1)
86+
rspec (3.13.0)
87+
rspec-core (~> 3.13.0)
88+
rspec-expectations (~> 3.13.0)
89+
rspec-mocks (~> 3.13.0)
90+
rspec-core (3.13.3)
91+
rspec-support (~> 3.13.0)
92+
rspec-expectations (3.13.3)
93+
diff-lcs (>= 1.2.0, < 2.0)
94+
rspec-support (~> 3.13.0)
95+
rspec-mocks (3.13.2)
96+
diff-lcs (>= 1.2.0, < 2.0)
97+
rspec-support (~> 3.13.0)
98+
rspec-support (3.13.2)
99+
rubocop (1.18.4)
100+
parallel (~> 1.10)
101+
parser (>= 3.0.0.0)
102+
rainbow (>= 2.2.2, < 4.0)
103+
regexp_parser (>= 1.8, < 3.0)
104+
rexml
105+
rubocop-ast (>= 1.8.0, < 2.0)
106+
ruby-progressbar (~> 1.7)
107+
unicode-display_width (>= 1.4.0, < 3.0)
108+
rubocop-ast (1.38.1)
109+
parser (>= 3.3.1.0)
110+
rubocop-jekyll (0.12.0)
111+
rubocop (~> 1.18.0)
112+
rubocop-performance (~> 1.2)
113+
rubocop-performance (1.19.1)
114+
rubocop (>= 1.7.0, < 2.0)
115+
rubocop-ast (>= 0.4.0)
116+
ruby-progressbar (1.13.0)
67117
safe_yaml (1.0.5)
68118
sass-embedded (1.83.0-x64-mingw-ucrt)
69119
google-protobuf (~> 4.28)
120+
sass-embedded (1.83.0-x86_64-linux-gnu)
121+
google-protobuf (~> 4.28)
70122
terminal-table (3.0.2)
71123
unicode-display_width (>= 1.1.1, < 3)
124+
typhoeus (1.4.1)
125+
ethon (>= 0.9.0)
72126
unicode-display_width (2.6.0)
73127
webrick (1.9.1)
74128

@@ -77,7 +131,14 @@ PLATFORMS
77131
x86_64-linux
78132

79133
DEPENDENCIES
134+
bundler
80135
jekyll-transcode-image-filters!
136+
nokogiri (~> 1.6)
137+
rake (~> 13.0)
138+
rspec (~> 3.0)
139+
rubocop
140+
rubocop-jekyll (~> 0.12.0)
141+
typhoeus (>= 0.7, < 2.0)
81142

82143
BUNDLED WITH
83144
2.5.22

Rakefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
BIN_FOLDER = "bin"
2-
GEMSPEC = ".gemspec"
1+
# frozen_string_literal: true
2+
3+
BIN_FOLDER = 'bin'
4+
GEMSPEC = '.gemspec'
35

46
def _package_name(spec)
57
package_name = spec.name
@@ -16,25 +18,30 @@ task :build do
1618

1719
# Build the gem
1820
system("gem build #{GEMSPEC}")
19-
spec = Gem::Specification::load(GEMSPEC)
21+
spec = Gem::Specification.load(GEMSPEC)
2022

2123
# Move the artifact into the bin folder
2224
package_name = _package_name(spec)
2325
File.rename("#{package_name}.gem", "#{BIN_FOLDER}/#{package_name}.gem")
2426
end
2527

26-
task :install => :build do
28+
task :test do
29+
# Test the gem
30+
system('bundle exec rspec .')
31+
end
32+
33+
task install: :build do
2734
# Uninstall and install the gem
28-
spec = Gem::Specification::load(GEMSPEC)
35+
spec = Gem::Specification.load(GEMSPEC)
2936
package_name = _package_name(spec)
3037
system("gem uninstall #{package_name}")
3138
system("gem install #{BIN_FOLDER}/#{package_name}.gem")
3239
end
3340

34-
task :publish => :build do
41+
task publish: :build do
3542
# Build and push the gem
36-
spec = Gem::Specification::load(GEMSPEC)
43+
spec = Gem::Specification.load(GEMSPEC)
3744
package_name = _package_name(spec)
3845
puts(package_name)
3946
system("gem push #{BIN_FOLDER}/#{package_name}.gem")
40-
end
47+
end

lib/jekyll-transcode-image-filters.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/jekyll-transcode-image-filters/version.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)