Added rspec testing. It should work, but doesn't for unknown reasons

This commit is contained in:
Gregory Ballantine
2025-08-12 15:35:46 -04:00
parent e1f5bd3950
commit 260d0d1268
5 changed files with 58 additions and 0 deletions

View File

@ -17,3 +17,8 @@ group :development, :test do
gem 'rubocop'
gem 'rubocop-sequel'
end
group :test do
gem 'rspec'
gem 'rack-test'
end

View File

@ -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)

View File

@ -24,6 +24,10 @@ namespace :server do
end
namespace :test do
task :unit do
system("rspec")
end
task :rubocop do
system("rubocop src/")
end

14
spec/routes/index_spec.rb Normal file
View File

@ -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

17
spec/spec_helper.rb Normal file
View File

@ -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