Switch to RSpec
All checks were successful
Gitea Actions Demo / lint (push) Successful in 1m21s
Gitea Actions Demo / test (push) Successful in 1m17s
Gitea Actions Demo / release-image (push) Successful in 59s

This commit is contained in:
Ryan Cavicchioni 2024-07-07 20:14:02 -05:00
parent 3b5e0f5c71
commit ca7d22374d
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
5 changed files with 38 additions and 25 deletions

View File

@ -38,7 +38,7 @@ jobs:
ruby-version: '3.3' ruby-version: '3.3'
bundler-cache: true bundler-cache: true
- run: ruby app_test.rb - run: bundle exec rspec
release-image: release-image:

View File

@ -18,6 +18,6 @@ group :development do
gem "rubocop" gem "rubocop"
gem "rbs" gem "rbs"
gem "rack-test" gem "rack-test"
gem "test-unit" gem "rspec"
gem "standard" gem "standard"
end end

View File

@ -4,6 +4,7 @@ GEM
anyflake (0.0.1) anyflake (0.0.1)
ast (2.4.2) ast (2.4.2)
base64 (0.2.0) base64 (0.2.0)
diff-lcs (1.5.1)
json (2.7.2) json (2.7.2)
jwt (2.8.2) jwt (2.8.2)
base64 base64
@ -20,7 +21,6 @@ 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)
@ -42,6 +42,19 @@ GEM
regexp_parser (2.9.2) regexp_parser (2.9.2)
rexml (3.3.0) rexml (3.3.0)
strscan strscan
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.64.1) rubocop (1.64.1)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
@ -91,8 +104,6 @@ GEM
lint_roller (~> 1.1) lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0) rubocop-performance (~> 1.21.0)
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)
@ -114,12 +125,12 @@ DEPENDENCIES
rack-test rack-test
rackup rackup
rbs rbs
rspec
rubocop rubocop
ruby-lsp ruby-lsp
sinatra sinatra
sinatra-contrib sinatra-contrib
standard standard
test-unit
ulid ulid
uuid7 uuid7

View File

@ -1,19 +0,0 @@
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!\n", last_response.body
end
end

21
spec/app_spec.rb Normal file
View File

@ -0,0 +1,21 @@
ENV["APP_ENV"] = "test"
require "./app"
require "rspec"
require "rack/test"
describe "Toy App" do
include Rack::Test::Methods
def app
Sinatra::Application
end
context "test /" do
it "test root route" do
get "/"
expect(last_response).to be_ok
expect(last_response.body).to eq("hello there!\n")
end
end
end