Add a unit test
This commit is contained in:
parent
5aeb90a18d
commit
dfcea7ad37
@ -4,7 +4,23 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-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:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
|
2
Gemfile
2
Gemfile
@ -17,4 +17,6 @@ group :development do
|
||||
gem "ruby-lsp"
|
||||
gem "rubocop"
|
||||
gem "rbs"
|
||||
gem "rack-test"
|
||||
gem "test-unit"
|
||||
end
|
||||
|
@ -19,6 +19,7 @@ GEM
|
||||
parser (3.3.3.0)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
power_assert (2.0.3)
|
||||
prism (0.30.0)
|
||||
puma (6.4.2)
|
||||
nio4r (~> 2.0)
|
||||
@ -29,6 +30,8 @@ GEM
|
||||
rack (>= 3.0.0, < 4)
|
||||
rack-session (2.0.0)
|
||||
rack (>= 3.0.0)
|
||||
rack-test (2.1.0)
|
||||
rack (>= 1.3)
|
||||
rackup (2.1.0)
|
||||
rack (>= 3)
|
||||
webrick (~> 1.8)
|
||||
@ -72,6 +75,8 @@ GEM
|
||||
tilt (~> 2.0)
|
||||
sorbet-runtime (0.5.11435)
|
||||
strscan (3.1.0)
|
||||
test-unit (3.6.2)
|
||||
power_assert
|
||||
tilt (2.3.0)
|
||||
ulid (1.4.0)
|
||||
unicode-display_width (2.5.0)
|
||||
@ -90,12 +95,14 @@ DEPENDENCIES
|
||||
ksuid
|
||||
nanoid
|
||||
puma
|
||||
rack-test
|
||||
rackup
|
||||
rbs
|
||||
rubocop
|
||||
ruby-lsp
|
||||
sinatra
|
||||
sinatra-contrib
|
||||
test-unit
|
||||
ulid
|
||||
uuid7
|
||||
|
||||
|
19
app_test.rb
Normal file
19
app_test.rb
Normal 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 there!".encode("ASCII"), last_response.body
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user