Skip to content

Commit 995a702

Browse files
cursoragentjaracursorsh
andcommitted
Add comprehensive Minitest test suite with in-memory DB setup
Co-authored-by: jaracursorsh <jaracursorsh@mitomail.com>
1 parent 47ed9ab commit 995a702

File tree

11 files changed

+901
-3
lines changed

11 files changed

+901
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
/spec/reports/
88
/tmp/
99
/dist
10-
*.gem
10+
*.gem
11+
/vendor/

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121

2222
## [0.1.0] - 2024-08-29
2323

24-
- Initial test release (not production ready)
24+
- Initial test release (not production ready)
25+
26+
## Unreleased
27+
- Add comprehensive Minitest test suite, in-memory DB setup, coverage, and CI-ready test task.

Gemfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,14 @@ source "https://rubygems.org"
66
gemspec
77

88
gem "rake", "~> 13.0"
9+
10+
group :development, :test do
11+
gem "minitest", "~> 5.22"
12+
gem "minitest-reporters", "~> 1.6"
13+
gem "rails", ">= 7.1", "< 9.0"
14+
gem "sqlite3", ">= 2.1"
15+
gem "database_cleaner-active_record", "~> 2.0"
16+
gem "webmock", "~> 3.23"
17+
gem "timecop", "~> 0.9"
18+
gem "simplecov", "~> 0.22", require: false
19+
end

Gemfile.lock

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
PATH
2+
remote: .
3+
specs:
4+
profitable (0.2.3)
5+
activesupport (>= 5.2)
6+
pay (>= 7.0.0)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
actioncable (8.0.2)
12+
actionpack (= 8.0.2)
13+
activesupport (= 8.0.2)
14+
nio4r (~> 2.0)
15+
websocket-driver (>= 0.6.1)
16+
zeitwerk (~> 2.6)
17+
actionmailbox (8.0.2)
18+
actionpack (= 8.0.2)
19+
activejob (= 8.0.2)
20+
activerecord (= 8.0.2)
21+
activestorage (= 8.0.2)
22+
activesupport (= 8.0.2)
23+
mail (>= 2.8.0)
24+
actionmailer (8.0.2)
25+
actionpack (= 8.0.2)
26+
actionview (= 8.0.2)
27+
activejob (= 8.0.2)
28+
activesupport (= 8.0.2)
29+
mail (>= 2.8.0)
30+
rails-dom-testing (~> 2.2)
31+
actionpack (8.0.2)
32+
actionview (= 8.0.2)
33+
activesupport (= 8.0.2)
34+
nokogiri (>= 1.8.5)
35+
rack (>= 2.2.4)
36+
rack-session (>= 1.0.1)
37+
rack-test (>= 0.6.3)
38+
rails-dom-testing (~> 2.2)
39+
rails-html-sanitizer (~> 1.6)
40+
useragent (~> 0.16)
41+
actiontext (8.0.2)
42+
actionpack (= 8.0.2)
43+
activerecord (= 8.0.2)
44+
activestorage (= 8.0.2)
45+
activesupport (= 8.0.2)
46+
globalid (>= 0.6.0)
47+
nokogiri (>= 1.8.5)
48+
actionview (8.0.2)
49+
activesupport (= 8.0.2)
50+
builder (~> 3.1)
51+
erubi (~> 1.11)
52+
rails-dom-testing (~> 2.2)
53+
rails-html-sanitizer (~> 1.6)
54+
activejob (8.0.2)
55+
activesupport (= 8.0.2)
56+
globalid (>= 0.3.6)
57+
activemodel (8.0.2)
58+
activesupport (= 8.0.2)
59+
activerecord (8.0.2)
60+
activemodel (= 8.0.2)
61+
activesupport (= 8.0.2)
62+
timeout (>= 0.4.0)
63+
activestorage (8.0.2)
64+
actionpack (= 8.0.2)
65+
activejob (= 8.0.2)
66+
activerecord (= 8.0.2)
67+
activesupport (= 8.0.2)
68+
marcel (~> 1.0)
69+
activesupport (8.0.2)
70+
base64
71+
benchmark (>= 0.3)
72+
bigdecimal
73+
concurrent-ruby (~> 1.0, >= 1.3.1)
74+
connection_pool (>= 2.2.5)
75+
drb
76+
i18n (>= 1.6, < 2)
77+
logger (>= 1.4.2)
78+
minitest (>= 5.1)
79+
securerandom (>= 0.3)
80+
tzinfo (~> 2.0, >= 2.0.5)
81+
uri (>= 0.13.1)
82+
addressable (2.8.7)
83+
public_suffix (>= 2.0.2, < 7.0)
84+
ansi (1.5.0)
85+
base64 (0.3.0)
86+
benchmark (0.4.1)
87+
bigdecimal (3.2.2)
88+
builder (3.3.0)
89+
concurrent-ruby (1.3.5)
90+
connection_pool (2.5.3)
91+
crack (1.0.0)
92+
bigdecimal
93+
rexml
94+
crass (1.0.6)
95+
database_cleaner-active_record (2.2.2)
96+
activerecord (>= 5.a)
97+
database_cleaner-core (~> 2.0)
98+
database_cleaner-core (2.0.1)
99+
date (3.4.1)
100+
docile (1.4.1)
101+
drb (2.2.3)
102+
erb (5.0.2)
103+
erubi (1.13.1)
104+
globalid (1.2.1)
105+
activesupport (>= 6.1)
106+
hashdiff (1.2.0)
107+
i18n (1.14.7)
108+
concurrent-ruby (~> 1.0)
109+
io-console (0.8.1)
110+
irb (1.15.2)
111+
pp (>= 0.6.0)
112+
rdoc (>= 4.0.0)
113+
reline (>= 0.4.2)
114+
logger (1.7.0)
115+
loofah (2.24.1)
116+
crass (~> 1.0.2)
117+
nokogiri (>= 1.12.0)
118+
mail (2.8.1)
119+
mini_mime (>= 0.1.1)
120+
net-imap
121+
net-pop
122+
net-smtp
123+
marcel (1.0.4)
124+
mini_mime (1.1.5)
125+
minitest (5.25.5)
126+
minitest-reporters (1.7.1)
127+
ansi
128+
builder
129+
minitest (>= 5.0)
130+
ruby-progressbar
131+
net-imap (0.5.9)
132+
date
133+
net-protocol
134+
net-pop (0.1.2)
135+
net-protocol
136+
net-protocol (0.2.2)
137+
timeout
138+
net-smtp (0.5.1)
139+
net-protocol
140+
nio4r (2.7.4)
141+
nokogiri (1.18.9-aarch64-linux-gnu)
142+
racc (~> 1.4)
143+
nokogiri (1.18.9-aarch64-linux-musl)
144+
racc (~> 1.4)
145+
nokogiri (1.18.9-arm-linux-gnu)
146+
racc (~> 1.4)
147+
nokogiri (1.18.9-arm-linux-musl)
148+
racc (~> 1.4)
149+
nokogiri (1.18.9-arm64-darwin)
150+
racc (~> 1.4)
151+
nokogiri (1.18.9-x86_64-darwin)
152+
racc (~> 1.4)
153+
nokogiri (1.18.9-x86_64-linux-gnu)
154+
racc (~> 1.4)
155+
nokogiri (1.18.9-x86_64-linux-musl)
156+
racc (~> 1.4)
157+
pay (11.2.1)
158+
rails (>= 7.0.0)
159+
pp (0.6.2)
160+
prettyprint
161+
prettyprint (0.2.0)
162+
psych (5.2.6)
163+
date
164+
stringio
165+
public_suffix (6.0.2)
166+
racc (1.8.1)
167+
rack (3.2.0)
168+
rack-session (2.1.1)
169+
base64 (>= 0.1.0)
170+
rack (>= 3.0.0)
171+
rack-test (2.2.0)
172+
rack (>= 1.3)
173+
rackup (2.2.1)
174+
rack (>= 3)
175+
rails (8.0.2)
176+
actioncable (= 8.0.2)
177+
actionmailbox (= 8.0.2)
178+
actionmailer (= 8.0.2)
179+
actionpack (= 8.0.2)
180+
actiontext (= 8.0.2)
181+
actionview (= 8.0.2)
182+
activejob (= 8.0.2)
183+
activemodel (= 8.0.2)
184+
activerecord (= 8.0.2)
185+
activestorage (= 8.0.2)
186+
activesupport (= 8.0.2)
187+
bundler (>= 1.15.0)
188+
railties (= 8.0.2)
189+
rails-dom-testing (2.3.0)
190+
activesupport (>= 5.0.0)
191+
minitest
192+
nokogiri (>= 1.6)
193+
rails-html-sanitizer (1.6.2)
194+
loofah (~> 2.21)
195+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
196+
railties (8.0.2)
197+
actionpack (= 8.0.2)
198+
activesupport (= 8.0.2)
199+
irb (~> 1.13)
200+
rackup (>= 1.0.0)
201+
rake (>= 12.2)
202+
thor (~> 1.0, >= 1.2.2)
203+
zeitwerk (~> 2.6)
204+
rake (13.3.0)
205+
rdoc (6.14.2)
206+
erb
207+
psych (>= 4.0.0)
208+
reline (0.6.2)
209+
io-console (~> 0.5)
210+
rexml (3.4.1)
211+
ruby-progressbar (1.13.0)
212+
securerandom (0.4.1)
213+
simplecov (0.22.0)
214+
docile (~> 1.1)
215+
simplecov-html (~> 0.11)
216+
simplecov_json_formatter (~> 0.1)
217+
simplecov-html (0.13.2)
218+
simplecov_json_formatter (0.1.4)
219+
sqlite3 (2.7.3-aarch64-linux-gnu)
220+
sqlite3 (2.7.3-aarch64-linux-musl)
221+
sqlite3 (2.7.3-arm-linux-gnu)
222+
sqlite3 (2.7.3-arm-linux-musl)
223+
sqlite3 (2.7.3-arm64-darwin)
224+
sqlite3 (2.7.3-x86_64-darwin)
225+
sqlite3 (2.7.3-x86_64-linux-gnu)
226+
sqlite3 (2.7.3-x86_64-linux-musl)
227+
stringio (3.1.7)
228+
thor (1.4.0)
229+
timecop (0.9.10)
230+
timeout (0.4.3)
231+
tzinfo (2.0.6)
232+
concurrent-ruby (~> 1.0)
233+
uri (1.0.3)
234+
useragent (0.16.11)
235+
webmock (3.25.1)
236+
addressable (>= 2.8.0)
237+
crack (>= 0.3.2)
238+
hashdiff (>= 0.4.0, < 2.0.0)
239+
websocket-driver (0.8.0)
240+
base64
241+
websocket-extensions (>= 0.1.0)
242+
websocket-extensions (0.1.5)
243+
zeitwerk (2.7.3)
244+
245+
PLATFORMS
246+
aarch64-linux
247+
aarch64-linux-gnu
248+
aarch64-linux-musl
249+
arm-linux
250+
arm-linux-gnu
251+
arm-linux-musl
252+
arm64-darwin
253+
x86_64-darwin
254+
x86_64-linux
255+
x86_64-linux-musl
256+
257+
DEPENDENCIES
258+
database_cleaner-active_record (~> 2.0)
259+
minitest (~> 5.22)
260+
minitest-reporters (~> 1.6)
261+
profitable!
262+
rails (>= 7.1, < 9.0)
263+
rake (~> 13.0)
264+
simplecov (~> 0.22)
265+
sqlite3 (>= 2.1)
266+
timecop (~> 0.9)
267+
webmock (~> 3.23)
268+
269+
BUNDLED WITH
270+
2.7.1

Rakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# frozen_string_literal: true
22

33
require "bundler/gem_tasks"
4-
task default: %i[]
4+
require "rake/testtask"
5+
6+
Rake::TestTask.new(:test) do |t|
7+
t.libs << "test"
8+
t.pattern = "test/**/*_test.rb"
9+
t.warning = true
10+
end
11+
12+
task default: :test

test/profitable/engine_test.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# frozen_string_literal: true
2+
require "test_helper"
3+
4+
class EngineIntegrationTest < Minitest::Test
5+
include Rails.application.routes.url_helpers
6+
7+
def setup
8+
super
9+
# Define routes for the engine in the test app
10+
TestApp.routes.draw do
11+
mount Profitable::Engine => "/profitable"
12+
end
13+
end
14+
15+
def test_dashboard_renders
16+
# seed some data so view calls do not blow up
17+
customer = Pay::Customer.create!(processor: "stripe")
18+
Pay::Subscription.create!(
19+
customer: customer,
20+
processor: "stripe",
21+
status: "active",
22+
current_period_start: Time.now - 1.day,
23+
current_period_end: Time.now + 1.day,
24+
data: { "subscription_items" => [{ "price" => { "unit_amount" => 1000, "recurring" => { "interval" => "month", "interval_count" => 1 } } }] }
25+
)
26+
27+
app = Rack::Builder.new do
28+
map "/profitable" do
29+
run Profitable::Engine
30+
end
31+
end.to_app
32+
33+
env = Rack::MockRequest.env_for("/profitable")
34+
status, _headers, body_enum = app.call(env)
35+
body = String.new
36+
body_enum.each { |chunk| body << chunk }
37+
assert_equal 200, status
38+
assert_includes body, "total customers"
39+
assert_includes body, "MRR"
40+
assert_includes body, "Valuation at 3x ARR"
41+
end
42+
end

0 commit comments

Comments
 (0)