From ca7d22374de033458bfd07cc4a311cd9a47a250c Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 7 Jul 2024 20:14:02 -0500 Subject: [PATCH] Switch to RSpec --- .gitea/workflows/demo.yaml | 2 +- Gemfile | 2 +- Gemfile.lock | 19 +++++++++++++++---- app_test.rb | 19 ------------------- spec/app_spec.rb | 21 +++++++++++++++++++++ 5 files changed, 38 insertions(+), 25 deletions(-) delete mode 100644 app_test.rb create mode 100644 spec/app_spec.rb diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 8ccf895..a19a073 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -38,7 +38,7 @@ jobs: ruby-version: '3.3' bundler-cache: true - - run: ruby app_test.rb + - run: bundle exec rspec release-image: diff --git a/Gemfile b/Gemfile index acfb954..0c1240d 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,6 @@ group :development do gem "rubocop" gem "rbs" gem "rack-test" - gem "test-unit" + gem "rspec" gem "standard" end diff --git a/Gemfile.lock b/Gemfile.lock index 56dc5f1..0596fa7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,6 +4,7 @@ GEM anyflake (0.0.1) ast (2.4.2) base64 (0.2.0) + diff-lcs (1.5.1) json (2.7.2) jwt (2.8.2) base64 @@ -20,7 +21,6 @@ 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) @@ -42,6 +42,19 @@ GEM regexp_parser (2.9.2) rexml (3.3.0) 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) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -91,8 +104,6 @@ GEM lint_roller (~> 1.1) rubocop-performance (~> 1.21.0) 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) @@ -114,12 +125,12 @@ DEPENDENCIES rack-test rackup rbs + rspec rubocop ruby-lsp sinatra sinatra-contrib standard - test-unit ulid uuid7 diff --git a/app_test.rb b/app_test.rb deleted file mode 100644 index 1d355db..0000000 --- a/app_test.rb +++ /dev/null @@ -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 diff --git a/spec/app_spec.rb b/spec/app_spec.rb new file mode 100644 index 0000000..8c48c29 --- /dev/null +++ b/spec/app_spec.rb @@ -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