Skip to content

Commit 4e8257a

Browse files
drwlMaimer
andauthored
Add integration tests (#60)
This PR adds integration tests to the project. It builds off the work done in #54, but using a freshly generated Rails app in [494a54f](494a54f). Notable changes: * Deletes `dummyapp` that existed in project root in favor of `spec/dummyapp` * The source of truth for annotations from different database adapters are checked in, and can be found in `spec/templates` * Adds integration tests to CI Credit to @Maimer for laying the foundation for supporting multiple adapters and creating concise models and migrations for testing. --------- Co-authored-by: Nicholas Lee <[email protected]>
1 parent b22fc47 commit 4e8257a

File tree

93 files changed

+442
-699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+442
-699
lines changed

.github/workflows/ci.yml

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,104 @@ jobs:
2929
ruby-version: ${{ matrix.ruby }}
3030
bundler-cache: true
3131

32-
- name: Run Tests
33-
run: bundle exec rspec
32+
- name: Run Unit tests
33+
run: bundle exec rake spec:unit
3434

3535
- name: Run Standard linter
3636
run: bundle exec standardrb
37+
38+
integration:
39+
runs-on: ubuntu-latest
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
# adapter: [ 'mysql2', 'pg', 'sqlite3' ]
44+
ruby: [ '2.7', '3.0', '3.1', '3.2' ]
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v3
49+
50+
- name: Setup Ruby
51+
uses: ruby/setup-ruby@v1
52+
with:
53+
ruby-version: ${{ matrix.ruby }}
54+
bundler-cache: true
55+
56+
- name: Start MySQL
57+
run: sudo systemctl start mysql.service
58+
59+
- name: Start and setup Postgres
60+
run: |
61+
sudo systemctl start postgresql.service
62+
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'root'"
63+
# https://github.com/actions/runner-images/issues/7678
64+
65+
- name: Install dummyapp dependencies (sqlite)
66+
run: bundle install
67+
working-directory: spec/dummyapp
68+
env:
69+
DATABASE_ADAPTER: sqlite3
70+
71+
- name: Run dummyapp migrations (sqlite)
72+
run: bin/rails db:create && bin/rails db:migrate
73+
working-directory: spec/dummyapp
74+
env:
75+
DATABASE_ADAPTER: sqlite3
76+
77+
- name: Run Integration tests (sqlite)
78+
run: bundle exec rake spec:integration
79+
env:
80+
DATABASE_ADAPTER: sqlite3
81+
82+
- name: Clean dummyapp (sqlite)
83+
run: |
84+
rm -f Gemfile.lock
85+
rm -f db/schema.rb
86+
working-directory: spec/dummyapp
87+
88+
- name: Install dummyapp dependencies (mysql2)
89+
run: bundle install
90+
working-directory: spec/dummyapp
91+
env:
92+
DATABASE_ADAPTER: mysql2
93+
94+
- name: Run dummyapp migrations (mysql2)
95+
run: bin/rails db:create && bin/rails db:migrate
96+
working-directory: spec/dummyapp
97+
env:
98+
DATABASE_ADAPTER: mysql2
99+
100+
- name: Run Integration tests (mysql2)
101+
run: bundle exec rake spec:integration
102+
env:
103+
DATABASE_ADAPTER: mysql2
104+
105+
- name: Clean dummyapp (mysql2)
106+
run: |
107+
rm -f Gemfile.lock
108+
rm -f db/schema.rb
109+
working-directory: spec/dummyapp
110+
111+
- name: Install dummyapp dependencies (pg)
112+
run: bundle install
113+
working-directory: spec/dummyapp
114+
env:
115+
DATABASE_ADAPTER: pg
116+
117+
- name: Run dummyapp migrations (pg)
118+
run: bin/rails db:create && bin/rails db:migrate
119+
working-directory: spec/dummyapp
120+
env:
121+
DATABASE_ADAPTER: pg
122+
123+
- name: Run Integration tests (pg)
124+
run: bundle exec rake spec:integration
125+
env:
126+
DATABASE_ADAPTER: pg
127+
128+
- name: Clean dummyapp (pg)
129+
run: |
130+
rm -f Gemfile.lock
131+
rm -f db/schema.rb
132+
working-directory: spec/dummyapp

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
/pkg/*
1616
/spec/debug.log
1717
.byebug_history
18-
.rspec_status
18+
.rspec_status
19+
/spec/dummyapp/Gemfile.lock
20+
/spec/dummyapp/log/
21+
/spec/dummyapp/db/schema.rb
22+
/spec/dummyapp/db/development.sqlite3
23+
/tmp/*

.standard.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ format: progress
33
ruby_version: 2.7
44
ignore:
55
- 'dummyapp/**/*'
6+
- 'spec/dummyapp/**/*'

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# frozen_string_literal: true
2+
13
source "https://rubygems.org"
2-
gemspec
34

45
gem "activerecord", require: false
56
gem "rake"
@@ -18,3 +19,5 @@ group :development, :test do
1819
gem "pry-byebug", require: false
1920
end
2021
end
22+
23+
gemspec

Rakefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
require "bundler/gem_tasks"
1+
# frozen_string_literal: true
2+
3+
require "bundler"
24
require "rspec/core/rake_task"
35

4-
RSpec::Core::RakeTask.new(:spec)
6+
namespace :spec do
7+
RSpec::Core::RakeTask.new(:unit) do |test|
8+
test.pattern = "spec/lib/**/*_spec.rb"
9+
end
10+
11+
RSpec::Core::RakeTask.new(:integration) do |test|
12+
test.pattern = "spec/integration/**/*_spec.rb"
13+
end
14+
end
15+
16+
task spec: ["spec:unit", "spec:integration"]
517

618
task default: :spec

dummyapp/.gitattributes

Lines changed: 0 additions & 7 deletions
This file was deleted.

dummyapp/.gitignore

Lines changed: 0 additions & 29 deletions
This file was deleted.

dummyapp/Gemfile.lock

Lines changed: 0 additions & 200 deletions
This file was deleted.

dummyapp/app/assets/images/.keep

Whitespace-only changes.

dummyapp/app/controllers/concerns/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)