From 260d0d1268e9324953c22f3750172f48ba105877 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Tue, 12 Aug 2025 15:35:46 -0400 Subject: [PATCH] Added rspec testing. It should work, but doesn't for unknown reasons --- Gemfile | 5 +++++ Gemfile.lock | 18 ++++++++++++++++++ Rakefile | 4 ++++ spec/routes/index_spec.rb | 14 ++++++++++++++ spec/spec_helper.rb | 17 +++++++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 spec/routes/index_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/Gemfile b/Gemfile index fc46a9e..0ca0db1 100644 --- a/Gemfile +++ b/Gemfile @@ -17,3 +17,8 @@ group :development, :test do gem 'rubocop' gem 'rubocop-sequel' end + +group :test do + gem 'rspec' + gem 'rack-test' +end diff --git a/Gemfile.lock b/Gemfile.lock index 8bcfd2f..1d8830a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,6 +4,7 @@ GEM ast (2.4.3) base64 (0.3.0) bigdecimal (3.2.2) + diff-lcs (1.6.2) ffi (1.17.2-aarch64-linux-gnu) ffi (1.17.2-aarch64-linux-musl) ffi (1.17.2-arm-linux-gnu) @@ -41,6 +42,8 @@ GEM rack-session (2.1.1) base64 (>= 0.1.0) rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) rainbow (3.1.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) @@ -48,6 +51,19 @@ GEM regexp_parser (2.10.0) rerun (0.14.0) listen (~> 3.0) + rspec (3.13.1) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.5) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.4) rubocop (1.76.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) @@ -112,7 +128,9 @@ PLATFORMS DEPENDENCIES logger puma (~> 6.6) + rack-test rerun + rspec rubocop rubocop-sequel sequel (~> 5.92) diff --git a/Rakefile b/Rakefile index 91676e7..eb02513 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,10 @@ namespace :server do end namespace :test do + task :unit do + system("rspec") + end + task :rubocop do system("rubocop src/") end diff --git a/spec/routes/index_spec.rb b/spec/routes/index_spec.rb new file mode 100644 index 0000000..d750b85 --- /dev/null +++ b/spec/routes/index_spec.rb @@ -0,0 +1,14 @@ +require_relative '../spec_helper' + +RSpec.describe IndexRoutes do + + def app + IndexRoutes + end + + it "Dashboard returns 200" do + get '/' + expect(last_response).to be_ok + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..8c4fef3 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,17 @@ +ENV['APP_ENV'] = 'test' + +require_relative '../src/app' +require 'rspec' +require 'rack/test' + +module RSpecMixin + include Rack::Test::Methods + + def app + GameData + end +end + +RSpec.configure do |config| + config.include RSpecMixin +end