Skip to content

Commit 99cc548

Browse files
authored
Modernize gem. (#37)
* Migrate tests to sus.
1 parent 958eb10 commit 99cc548

File tree

166 files changed

+1793
-1785
lines changed

Some content is hidden

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

166 files changed

+1793
-1785
lines changed

.github/workflows/coverage.yaml

+15-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,22 @@ jobs:
3030
ruby-version: ${{matrix.ruby}}
3131
bundler-cache: true
3232

33+
- name: Installing packages (ubuntu)
34+
if: matrix.os == 'ubuntu'
35+
run: sudo apt-get install wget
36+
37+
- name: Installing packages (macos)
38+
if: matrix.os == 'macos'
39+
run: brew install wget
40+
3341
- name: Run tests
34-
timeout-minutes: 5
35-
run: bundle exec bake test
36-
42+
timeout-minutes: 10
43+
run: |
44+
git config --global user.email "samuel@oriontransfer.net"
45+
git config --global user.name "Samuel Williams"
46+
git config --global init.defaultBranch main
47+
bundle exec bake test
48+
3749
- uses: actions/upload-artifact@v2
3850
with:
3951
name: coverage-${{matrix.os}}-${{matrix.ruby}}

.github/workflows/documentation.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- uses: ruby/setup-ruby@v1
3434
with:
35-
ruby-version: "3.1"
35+
ruby-version: "3.2"
3636
bundler-cache: true
3737

3838
- name: Installing packages

.github/workflows/test-external.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Test External
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
env:
9+
CONSOLE_OUTPUT: XTerm
10+
11+
jobs:
12+
test:
13+
name: ${{matrix.ruby}} on ${{matrix.os}}
14+
runs-on: ${{matrix.os}}-latest
15+
16+
strategy:
17+
matrix:
18+
os:
19+
- ubuntu
20+
- macos
21+
22+
ruby:
23+
- "2.7"
24+
- "3.0"
25+
- "3.1"
26+
- "3.2"
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
- uses: ruby/setup-ruby@v1
31+
with:
32+
ruby-version: ${{matrix.ruby}}
33+
bundler-cache: true
34+
35+
- name: Run tests
36+
timeout-minutes: 10
37+
run: bundle exec bake test:external

.github/workflows/test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ jobs:
6060
git config --global user.email "samuel@oriontransfer.net"
6161
git config --global user.name "Samuel Williams"
6262
git config --global init.defaultBranch main
63-
bundle exec rspec
63+
bundle exec bake test

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
/gems.locked
44
/.covered.db
55
/external
6-
7-
.rspec
8-
.rspec_status

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Samuel Williams <root@Nekomimi.local>
2+
Pierre Montelle <k1tsu@github.com>

.rspec

-4
This file was deleted.

bake/utopia/test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2020-2022, by Samuel Williams.
4+
# Copyright, 2020-2023, by Samuel Williams.
55

66
def coverage
77
ENV['COVERAGE'] = 'PartialSummary'
88
end
99

1010
def test
11-
system("rspec") or abort
11+
system("sus") or abort
1212
end

config/sus.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2023, by Samuel Williams.
5+
6+
require 'covered/sus'
7+
include Covered::Sus
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2016-2022, by Samuel Williams.
4+
# Copyright, 2016-2023, by Samuel Williams.
55

66
require 'rack/test'
7+
require 'rack/builder'
78

8-
RSpec.shared_context "rack app" do |relative_rackup_path|
9+
ARackApplication = Sus::Shared("a rack app") do |rackup_path|
910
include Rack::Test::Methods
1011

11-
let(:rackup_path) {File.expand_path(relative_rackup_path, __dir__)}
1212
let(:rackup_directory) {File.dirname(rackup_path)}
13-
1413
let(:app) {Rack::Builder.parse_file(rackup_path)}
1514
end

gems.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2012-2022, by Samuel Williams.
4+
# Copyright, 2012-2023, by Samuel Williams.
55

66
source 'https://rubygems.org'
77

@@ -22,6 +22,8 @@
2222
group :test do
2323
gem 'bake-gem'
2424
gem 'bake-test'
25+
gem 'bake-test-external'
26+
2527
gem 'benchmark-ips'
2628

2729
gem 'guard-falcon'
@@ -30,3 +32,4 @@
3032
end
3133

3234
gem "thread-local", "~> 1.0"
35+
# gem "sus", path: "../../ioquatix/sus"
File renamed without changes.
File renamed without changes.

guides/server-setup/README.md renamed to guides/server-setup/readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- ubuntu
7272

7373
ruby:
74-
- 2.7
74+
- "3.2"
7575

7676
runs-on: ${{matrix.os}}-latest
7777

@@ -93,7 +93,7 @@ jobs:
9393
bundle config path vendor/bundle
9494
bundle install --jobs 4 --retry 3
9595
- name: Run tests
96-
run: ${{matrix.env}} bundle exec rspec
96+
run: ${{matrix.env}} bundle exec sus
9797

9898
deploy:
9999
needs: test
File renamed without changes.
File renamed without changes.

lib/utopia/command/site.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2017-2022, by Samuel Williams.
4+
# Copyright, 2017-2023, by Samuel Williams.
55
# Copyright, 2020, by Michael Adams.
66

77
require 'fileutils'
@@ -17,7 +17,7 @@ module Command
1717
# Local site setup commands.
1818
class Site < Samovar::Command
1919
# Configuration files which should be installed/updated:
20-
CONFIGURATION_FILES = ['.gitignore', 'config.ru', 'config/environment.rb', 'falcon.rb', 'gems.rb', 'Guardfile', 'bake.rb', 'spec/spec_helper.rb', 'spec/website_context.rb', 'spec/website_spec.rb']
20+
CONFIGURATION_FILES = ['.gitignore', 'config.ru', 'config/environment.rb', 'falcon.rb', 'gems.rb', 'Guardfile', 'bake.rb', 'test/website.rb', 'fixtures/website.rb']
2121

2222
# Directories that should exist:
2323
DIRECTORIES = ["config", "lib", "pages", "public", "tasks", "spec"]

license.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# MIT License
22

3-
Copyright, 2009-2022, by Samuel Williams.
3+
Copyright, 2009-2023, by Samuel Williams.
44
Copyright, 2015-2019, by Huba Nagy.
55
Copyright, 2020, by Olle Jonsson.
6-
Copyright, 2020, by k1tsu.
6+
Copyright, 2020, by Pierre Montelle.
77
Copyright, 2020, by Michael Adams.
88

99
Permission is hereby granted, free of charge, to any person obtaining a copy

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Utopia is a website generation framework which provides a robust set of tools to build highly complex dynamic websites. It uses the filesystem heavily for content and provides functions for interacting with files and directories as structure representing the website.
44

5-
[![Development Status](https://github.com/socketry/utopia/workflows/Test/badge.svg)](https://github.com/socketry/utopia/actions?workflow=Test)
5+
[![Development Status](https://github.com/ioquatix/utopia/workflows/Test/badge.svg)](https://github.com/ioquatix/utopia/actions?workflow=Test)
66

77
## Features
88

setup/site/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Development specific:
2-
/.rspec_status
32
/.bundle
43

54
# Temporary data should not be added to the repository:

setup/site/.rspec

-4
This file was deleted.

setup/site/Guardfile

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ group :development do
1010
end
1111

1212
group :test do
13-
guard :rspec, cmd: 'rspec' do
14-
# Notifications can get a bit tedious:
15-
# notification :off
13+
# guard :rspec, cmd: 'rspec' do
14+
# # Notifications can get a bit tedious:
15+
# # notification :off
1616

17-
# Re-run specs if they are changed:
18-
watch(%r{^spec/.+_spec\.rb$})
19-
watch('spec/spec_helper.rb') {'spec'}
17+
# # Re-run specs if they are changed:
18+
# watch(%r{^spec/.+_spec\.rb$})
19+
# watch('spec/spec_helper.rb') {'spec'}
2020

21-
# Run relevent specs if files in `lib/` or `pages/` are changed:
22-
watch(%r{^lib/(.+)\.rb$}) {|match| "spec/lib/#{match[1]}_spec.rb" }
23-
watch(%r{^pages/(.+)\.(rb|xnode)$}) {|match| "spec/pages/#{match[1]}_spec.rb"}
24-
watch(%r{^pages/(.+)controller\.rb$}) {|match| Dir.glob("spec/pages/#{match[1]}*_spec.rb")}
21+
# # Run relevent specs if files in `lib/` or `pages/` are changed:
22+
# watch(%r{^lib/(.+)\.rb$}) {|match| "spec/lib/#{match[1]}_spec.rb" }
23+
# watch(%r{^pages/(.+)\.(rb|xnode)$}) {|match| "spec/pages/#{match[1]}_spec.rb"}
24+
# watch(%r{^pages/(.+)controller\.rb$}) {|match| Dir.glob("spec/pages/#{match[1]}*_spec.rb")}
2525

26-
# If any files in pages changes, ensure the website still works:
27-
watch(%r{^pages/.*}) {'spec/website_spec.rb'}
28-
end
26+
# # If any files in pages changes, ensure the website still works:
27+
# watch(%r{^pages/.*}) {'spec/website_spec.rb'}
28+
# end
2929
end
File renamed without changes.

setup/site/config/sus.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2023, by Samuel Williams.
5+
6+
require 'variant'
7+
Variant.force!(:testing)
8+
9+
require 'covered/sus'
10+
include Covered::Sus

setup/site/fixtures/website.rb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2016-2023, by Samuel Williams.
5+
6+
require 'rack/test'
7+
require 'sus/fixtures/async/http'
8+
require 'protocol/rack'
9+
10+
AWebsite = Sus::Shared("a website") do
11+
include Rack::Test::Methods
12+
13+
let(:rackup_path) {File.expand_path('../config.ru', __dir__)}
14+
let(:rackup_directory) {File.dirname(rackup_path)}
15+
16+
let(:app) {Rack::Builder.parse_file(rackup_path)}
17+
end
18+
19+
AValidPage = Sus::Shared("a valid page") do |path|
20+
it "can access #{path}" do
21+
get path
22+
23+
while last_response.redirect?
24+
follow_redirect!
25+
end
26+
27+
expect(last_response.status).to be == 200
28+
end
29+
end
30+
31+
AServer = Sus::Shared("a server") do
32+
include Sus::Fixtures::Async::HTTP::ServerContext
33+
34+
let(:rackup_path) {File.expand_path('../config.ru', __dir__)}
35+
let(:rackup_directory) {File.dirname(rackup_path)}
36+
37+
let(:rack_app) {Rack::Builder.parse_file(rackup_path)}
38+
let(:app) {Protocol::Rack::Adapter.new(rack_app)}
39+
end

setup/site/gems.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2012-2022, by Samuel Williams.
4+
# Copyright, 2012-2023, by Samuel Williams.
55

66
source 'https://rubygems.org'
77

@@ -13,20 +13,19 @@
1313
gem 'variant'
1414
end
1515

16-
gem 'rake'
1716
gem 'bake'
1817
gem 'bundler'
1918
gem 'rack-test'
2019
gem 'net-smtp'
2120

2221
group :development do
2322
gem 'guard-falcon', require: false
24-
gem 'guard-rspec', require: false
2523

26-
gem 'rspec'
24+
gem 'sus'
25+
gem 'sus-fixtures-async-http'
26+
2727
gem 'covered'
2828

29-
gem 'async-rspec'
3029
gem 'benchmark-http'
3130
end
3231

File renamed without changes.

setup/site/spec/spec_helper.rb

-19
This file was deleted.

0 commit comments

Comments
 (0)