Added rspec testing. It should work, but doesn't for unknown reasons
This commit is contained in:
5
Gemfile
5
Gemfile
@@ -17,3 +17,8 @@ group :development, :test do
|
|||||||
gem 'rubocop'
|
gem 'rubocop'
|
||||||
gem 'rubocop-sequel'
|
gem 'rubocop-sequel'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem 'rspec'
|
||||||
|
gem 'rack-test'
|
||||||
|
end
|
||||||
|
18
Gemfile.lock
18
Gemfile.lock
@@ -4,6 +4,7 @@ GEM
|
|||||||
ast (2.4.3)
|
ast (2.4.3)
|
||||||
base64 (0.3.0)
|
base64 (0.3.0)
|
||||||
bigdecimal (3.2.2)
|
bigdecimal (3.2.2)
|
||||||
|
diff-lcs (1.6.2)
|
||||||
ffi (1.17.2-aarch64-linux-gnu)
|
ffi (1.17.2-aarch64-linux-gnu)
|
||||||
ffi (1.17.2-aarch64-linux-musl)
|
ffi (1.17.2-aarch64-linux-musl)
|
||||||
ffi (1.17.2-arm-linux-gnu)
|
ffi (1.17.2-arm-linux-gnu)
|
||||||
@@ -41,6 +42,8 @@ GEM
|
|||||||
rack-session (2.1.1)
|
rack-session (2.1.1)
|
||||||
base64 (>= 0.1.0)
|
base64 (>= 0.1.0)
|
||||||
rack (>= 3.0.0)
|
rack (>= 3.0.0)
|
||||||
|
rack-test (2.2.0)
|
||||||
|
rack (>= 1.3)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
rb-fsevent (0.11.2)
|
rb-fsevent (0.11.2)
|
||||||
rb-inotify (0.11.1)
|
rb-inotify (0.11.1)
|
||||||
@@ -48,6 +51,19 @@ GEM
|
|||||||
regexp_parser (2.10.0)
|
regexp_parser (2.10.0)
|
||||||
rerun (0.14.0)
|
rerun (0.14.0)
|
||||||
listen (~> 3.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)
|
rubocop (1.76.1)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
language_server-protocol (~> 3.17.0.2)
|
language_server-protocol (~> 3.17.0.2)
|
||||||
@@ -112,7 +128,9 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
logger
|
logger
|
||||||
puma (~> 6.6)
|
puma (~> 6.6)
|
||||||
|
rack-test
|
||||||
rerun
|
rerun
|
||||||
|
rspec
|
||||||
rubocop
|
rubocop
|
||||||
rubocop-sequel
|
rubocop-sequel
|
||||||
sequel (~> 5.92)
|
sequel (~> 5.92)
|
||||||
|
4
Rakefile
4
Rakefile
@@ -24,6 +24,10 @@ namespace :server do
|
|||||||
end
|
end
|
||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
|
task :unit do
|
||||||
|
system("rspec")
|
||||||
|
end
|
||||||
|
|
||||||
task :rubocop do
|
task :rubocop do
|
||||||
system("rubocop src/")
|
system("rubocop src/")
|
||||||
end
|
end
|
||||||
|
14
spec/routes/index_spec.rb
Normal file
14
spec/routes/index_spec.rb
Normal 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
17
spec/spec_helper.rb
Normal 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
|
Reference in New Issue
Block a user