Add a unit test

This commit is contained in:
Ryan Cavicchioni 2024-07-06 16:06:53 -05:00
parent 5aeb90a18d
commit 850851f3f3
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
4 changed files with 45 additions and 0 deletions

View File

@ -4,6 +4,23 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push] on: [push]
jobs: jobs:
test:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- run: ruby app_test.rb
release-image: release-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:

View File

@ -17,4 +17,6 @@ group :development do
gem "ruby-lsp" gem "ruby-lsp"
gem "rubocop" gem "rubocop"
gem "rbs" gem "rbs"
gem "rack-test"
gem "test-unit"
end end

View File

@ -19,6 +19,7 @@ GEM
parser (3.3.3.0) parser (3.3.3.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
power_assert (2.0.3)
prism (0.30.0) prism (0.30.0)
puma (6.4.2) puma (6.4.2)
nio4r (~> 2.0) nio4r (~> 2.0)
@ -29,6 +30,8 @@ GEM
rack (>= 3.0.0, < 4) rack (>= 3.0.0, < 4)
rack-session (2.0.0) rack-session (2.0.0)
rack (>= 3.0.0) rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0) rackup (2.1.0)
rack (>= 3) rack (>= 3)
webrick (~> 1.8) webrick (~> 1.8)
@ -72,6 +75,8 @@ GEM
tilt (~> 2.0) tilt (~> 2.0)
sorbet-runtime (0.5.11435) sorbet-runtime (0.5.11435)
strscan (3.1.0) strscan (3.1.0)
test-unit (3.6.2)
power_assert
tilt (2.3.0) tilt (2.3.0)
ulid (1.4.0) ulid (1.4.0)
unicode-display_width (2.5.0) unicode-display_width (2.5.0)
@ -90,12 +95,14 @@ DEPENDENCIES
ksuid ksuid
nanoid nanoid
puma puma
rack-test
rackup rackup
rbs rbs
rubocop rubocop
ruby-lsp ruby-lsp
sinatra sinatra
sinatra-contrib sinatra-contrib
test-unit
ulid ulid
uuid7 uuid7

19
app_test.rb Normal file
View File

@ -0,0 +1,19 @@
ENV['APP_ENV'] = 'test'
require './app'
require 'test/unit'
require 'rack/test'
class ToyTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_root
get '/'
assert last_response.ok?
assert_equal 'hello', last_response.body
end
end