stack-service-base 0.0.55 → 0.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/stack-service-base/project_template/home/src/spec/integration/integration_spec.rb +13 -0
- data/lib/stack-service-base/project_template/home/src/spec/spec_helper.rb +7 -55
- data/lib/stack-service-base/project_template/home/src/spec/support/rack_helper.rb +58 -0
- data/lib/stack-service-base/project_template/home/src/spec/unit/audio_utils_spec.rb +13 -0
- data/lib/stack-service-base/rack_helpers.rb +5 -2
- data/lib/stack-service-base/version.rb +1 -1
- metadata +5 -3
- data/lib/stack-service-base/project_template/home/src/spec/integration_spec.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 93e0600204518262fd868f9aa5c6a8faa1abeab9fd3154499e5d213960ad198e
|
|
4
|
+
data.tar.gz: e34002d076c4158809b17bf77974de41a41bb9c6ee126ce3dc7650dd736784e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 498f96e043f0bc5f385bacd38f758b99c2ff7050f6ad6b4d706da5cbd9ae91725254a3835a39428af537f01eae4fe351e36930b5e9c801dc3a558d344141daf5
|
|
7
|
+
data.tar.gz: ac5043941ccc4f20ac9bbebb0124c14417efb69117c5a78aa9ac69e9c1e1c05656bf170830b11959374bfc4a6154ae85bc28d7f77d8cbcf06aa9c061c82ad7bd
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require_relative "../support/rack_helper"
|
|
3
|
+
|
|
4
|
+
RSpec.describe "Integration Tests", type: :request do
|
|
5
|
+
describe "Service basics" do
|
|
6
|
+
it "responds to healthcheck" do
|
|
7
|
+
get "/healthcheck"
|
|
8
|
+
expect(last_response.status).to eq(200)
|
|
9
|
+
body = JSON.parse(last_response.body)
|
|
10
|
+
expect(body.fetch("Status")).to eq("Healthy")
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,58 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require 'stack-service-base/logging'
|
|
5
|
-
require 'rspec-benchmark'
|
|
6
|
-
require 'rack/test'
|
|
7
|
-
require 'async/rspec'
|
|
8
|
-
require 'rack/builder'
|
|
9
|
-
require "rspec/snapshot"
|
|
10
|
-
require 'testcontainers'
|
|
11
|
-
require 'simplecov'
|
|
1
|
+
require "rspec"
|
|
2
|
+
require "simplecov"
|
|
12
3
|
SimpleCov.start
|
|
13
4
|
|
|
14
|
-
#ENV['DB_URL'] = 'sqlite::memory:'
|
|
15
|
-
|
|
16
|
-
module Rack::Test::JHelpers
|
|
17
|
-
def app = RSpec.configuration.app
|
|
18
|
-
end
|
|
19
|
-
|
|
20
5
|
RSpec.configure do |config|
|
|
21
|
-
config.
|
|
22
|
-
config.
|
|
23
|
-
config.
|
|
24
|
-
config.
|
|
25
|
-
|
|
26
|
-
config.add_setting :pg_container
|
|
27
|
-
config.add_setting :app
|
|
28
|
-
|
|
29
|
-
config.before(:each) do
|
|
30
|
-
header 'Host', 'localhost'
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
config.before(:suite) do
|
|
34
|
-
db_url = ENV['TEST_DB_URL']
|
|
35
|
-
if db_url.nil?
|
|
36
|
-
pg_container = Testcontainers::DockerContainer
|
|
37
|
-
.new("postgis/postgis:16-3.4")
|
|
38
|
-
.with_exposed_port(5432)
|
|
39
|
-
.with_env("POSTGRES_USER", "test")
|
|
40
|
-
.with_env("POSTGRES_PASSWORD", "test")
|
|
41
|
-
.with_env("POSTGRES_DB", "app_test")
|
|
42
|
-
pg_container.logger = LOGGER
|
|
43
|
-
pg_container.add_wait_for(:logs, /database system is ready to accept connections/)
|
|
44
|
-
RSpec.configuration.pg_container = pg_container
|
|
45
|
-
pg_container.start
|
|
46
|
-
db_url = "postgres://test:test@#{pg_container.host}:#{pg_container.first_mapped_port}/app_test"
|
|
47
|
-
end
|
|
48
|
-
ENV['DB_URL'] = db_url
|
|
49
|
-
ENV['APP_ENV'] = "test"
|
|
50
|
-
RSpec.configuration.app = Rack::Builder.parse_file(File.expand_path('config.ru'))
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
config.after(:suite) do
|
|
54
|
-
return unless RSpec.configuration.pg_container
|
|
55
|
-
RSpec.configuration.pg_container.stop
|
|
56
|
-
RSpec.configuration.pg_container.delete
|
|
57
|
-
end
|
|
58
|
-
end
|
|
6
|
+
# config.expect_with :rspec do |c| c.syntax = :expect end
|
|
7
|
+
# config.disable_monkey_patching!
|
|
8
|
+
# config.order = :random
|
|
9
|
+
# Kernel.srand config.seed
|
|
10
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'stack-service-base/logging'
|
|
2
|
+
require 'rspec-benchmark'
|
|
3
|
+
require 'rack/test'
|
|
4
|
+
require 'async/rspec'
|
|
5
|
+
require 'rack/builder'
|
|
6
|
+
require "rspec/snapshot"
|
|
7
|
+
require 'testcontainers'
|
|
8
|
+
|
|
9
|
+
module Rack::Test::AppHelper
|
|
10
|
+
def app = RSpec.configuration.app
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
RSpec.configure do |config|
|
|
14
|
+
config.include Rack::Test::AppHelper, type: :request
|
|
15
|
+
config.include Rack::Test::Methods, type: :request
|
|
16
|
+
config.include RSpec::Benchmark::Matchers
|
|
17
|
+
config.include RSpec::Snapshot
|
|
18
|
+
config.include_context Async::RSpec::Reactor
|
|
19
|
+
config.add_setting :app
|
|
20
|
+
config.add_setting :pg_container
|
|
21
|
+
|
|
22
|
+
# Tag anything under /integration as :integration
|
|
23
|
+
# config.define_derived_metadata(file_path: %r{/spec/integration/}) { |m| m[:type] = :integration }
|
|
24
|
+
|
|
25
|
+
# ensure this only runs for request specs; avoid leaking into other types
|
|
26
|
+
config.before(type: :request) do
|
|
27
|
+
header 'Host', 'localhost'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Load Rack app only once when first integration test runs
|
|
31
|
+
config.before(:suite) do
|
|
32
|
+
if RSpec.world.filtered_examples.values.flatten.any? { |e| e.metadata[:type] == :request }
|
|
33
|
+
db_url = ENV['TEST_DB_URL']
|
|
34
|
+
if db_url.nil?
|
|
35
|
+
pg_container = Testcontainers::DockerContainer
|
|
36
|
+
.new("postgis/postgis:16-3.4")
|
|
37
|
+
.with_exposed_port(5432)
|
|
38
|
+
.with_env("POSTGRES_USER", "test")
|
|
39
|
+
.with_env("POSTGRES_PASSWORD", "test")
|
|
40
|
+
.with_env("POSTGRES_DB", "app_test")
|
|
41
|
+
pg_container.logger = LOGGER
|
|
42
|
+
pg_container.add_wait_for(:logs, /database system is ready to accept connections/)
|
|
43
|
+
RSpec.configuration.pg_container = pg_container
|
|
44
|
+
pg_container.start
|
|
45
|
+
db_url = "postgres://test:test@#{pg_container.host}:#{pg_container.first_mapped_port}/app_test"
|
|
46
|
+
end
|
|
47
|
+
ENV['DB_URL'] = db_url
|
|
48
|
+
rack_app, = Rack::Builder.parse_file(File.expand_path("../../config.ru", __dir__))
|
|
49
|
+
RSpec.configuration.app = rack_app
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
config.after(:suite) do
|
|
54
|
+
return unless RSpec.configuration.pg_container
|
|
55
|
+
RSpec.configuration.pg_container.stop
|
|
56
|
+
RSpec.configuration.pg_container.delete
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -169,8 +169,11 @@ module RackHelpers
|
|
|
169
169
|
end if defined? GrapeSwagger::DocMethods::ParseParams
|
|
170
170
|
|
|
171
171
|
app.use Rack.middleware_klass do |env, app|
|
|
172
|
-
|
|
173
|
-
env['PATH_INFO'] == '/healthcheck'
|
|
172
|
+
code, headers, body = env['REQUEST_METHOD'] == 'OPTIONS' ? [200, {}, []] : app.call(env)
|
|
173
|
+
if code == 404 && env['PATH_INFO'] == '/healthcheck'
|
|
174
|
+
code, headers, body = [200, {'Content-Type' =>'application/json'}, [{ Status: 'Healthy' }.to_json ]]
|
|
175
|
+
end
|
|
176
|
+
[code, headers, body]
|
|
174
177
|
end
|
|
175
178
|
|
|
176
179
|
if defined? OpenTelemetry::Instrumentation::Rack::Instrumentation
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stack-service-base
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.56
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Artyom B
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-11-
|
|
11
|
+
date: 2025-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -270,8 +270,10 @@ files:
|
|
|
270
270
|
- lib/stack-service-base/project_template/home/src/Gemfile.lock
|
|
271
271
|
- lib/stack-service-base/project_template/home/src/Rakefile
|
|
272
272
|
- lib/stack-service-base/project_template/home/src/config.ru
|
|
273
|
-
- lib/stack-service-base/project_template/home/src/spec/integration_spec.rb
|
|
273
|
+
- lib/stack-service-base/project_template/home/src/spec/integration/integration_spec.rb
|
|
274
274
|
- lib/stack-service-base/project_template/home/src/spec/spec_helper.rb
|
|
275
|
+
- lib/stack-service-base/project_template/home/src/spec/support/rack_helper.rb
|
|
276
|
+
- lib/stack-service-base/project_template/home/src/spec/unit/audio_utils_spec.rb
|
|
275
277
|
- lib/stack-service-base/project_template/home/src/views/index.slim
|
|
276
278
|
- lib/stack-service-base/project_template/home/src/views/layout.slim
|
|
277
279
|
- lib/stack-service-base/prometheus.rb
|