Skip to content

Commit d7c60ff

Browse files
authored
feat: setup dynamic rspec testing / good-bye manual test creation (#255)
* feat: setup dynamic rspec testing / good-bye manual test creation * feat: remove test files / not-required any longer * fix: add missing default param
1 parent 44c218d commit d7c60ff

54 files changed

Lines changed: 115 additions & 242 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,41 @@ test-fetch-all-configs:
1616

1717
test-all: test test-fetch-all-configs
1818

19+
# Dynamic test commands
20+
test-config:
21+
@if [ -z "$(CONFIG)" ]; then \
22+
echo "Usage: make test-config CONFIG=github.com/releases.yml"; \
23+
echo " make test-config CONFIG=github.com"; \
24+
exit 1; \
25+
fi
26+
bundle exec rspec --example "$(CONFIG)" spec/html2rss/configs_dynamic_spec.rb
27+
28+
test-domain:
29+
@if [ -z "$(DOMAIN)" ]; then \
30+
echo "Usage: make test-domain DOMAIN=github.com"; \
31+
exit 1; \
32+
fi
33+
bundle exec rspec --example "$(DOMAIN)" spec/html2rss/configs_dynamic_spec.rb
34+
35+
test-debug:
36+
@if [ -z "$(CONFIG)" ]; then \
37+
echo "Usage: make test-debug CONFIG=github.com/releases.yml"; \
38+
exit 1; \
39+
fi
40+
DEBUG_CONFIG=$(CONFIG) bundle exec rspec spec/html2rss/configs_dynamic_spec.rb
41+
42+
# Migration commands
43+
migrate-tests:
44+
bin/migrate_to_dynamic_tests
45+
46+
restore-tests:
47+
@if [ -d "spec/html2rss/configs_backup" ]; then \
48+
cp -r spec/html2rss/configs_backup/* spec/html2rss/configs/; \
49+
echo "✅ Restored tests from backup"; \
50+
else \
51+
echo "❌ No backup found"; \
52+
fi
53+
1954
lintfix:
2055
bundle exec rubocop -a
2156
npx prettier --write lib/**/*.yml .github/**/*.yml README.md

README.md

Lines changed: 17 additions & 0 deletions

bin/rspec_changed_configs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
changed_files = `git diff --name-only origin/master | grep 'lib/html2rss/configs/.*/.*.yml'`.split("\n")
55

6-
specs_to_run = changed_files.filter_map do |file|
7-
filepath = File.expand_path File.join(__dir__, '..', file)
6+
if changed_files.count.positive?
7+
# Use dynamic test file with environment variable to filter changed configs
8+
config_names = changed_files.map { |file| file.sub('lib/html2rss/configs/', '') }
89

9-
"#{file.gsub('lib/', 'spec/')}_spec.rb" if File.exist?(filepath)
10-
end
11-
12-
if specs_to_run.count.positive?
13-
exec "bundle exec rspec --tag fetch #{specs_to_run.join(' ')}"
10+
# Test each changed config individually
11+
config_names.each do |config_name|
12+
puts "Testing changed config: #{config_name}"
13+
system("bundle exec rspec --example '#{config_name}' --tag fetch spec/html2rss/configs_dynamic_spec.rb")
14+
end
1415
else
16+
puts 'No changed config files found'
1517
exit 0
1618
end

lib/html2rss/configs/apnews.com/hub.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
parameters:
3+
section:
4+
type: string
5+
default: "news"
6+
27
channel:
38
url: https://apnews.com/%<section>s
49
language: en

lib/html2rss/configs/cnet.com/section_sub.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---
2+
parameters:
3+
section:
4+
type: string
5+
default: "news"
6+
sub:
7+
type: string
8+
default: "tech"
9+
210
channel:
311
url: https://www.cnet.com/%<section>s/%<sub>s/
412
language: en

lib/html2rss/configs/webentwickler-jobs.de/in.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
parameters:
3+
region:
4+
type: string
5+
default: "berlin"
6+
27
channel:
38
url: https://www.webentwickler-jobs.de/in/%<region>s
49
language: de

spec/html2rss/configs/adfc.de/pressemitteilungen.yml_spec.rb

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

spec/html2rss/configs/apnews.com/hub.yml_spec.rb

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

spec/html2rss/configs/avherald.com/index.yml_spec.rb

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

spec/html2rss/configs/bbc.co.uk/available_episodes.yml_spec.rb

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

0 commit comments

Comments
 (0)