Skip to content

Commit e3a798c

Browse files
committed
Use Combustion gem to run tests
1 parent 5b81aed commit e3a798c

17 files changed

+88
-39
lines changed

.gitignore

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
/coverage
1111
/tmp
1212

13-
# Ignore sqlite db file
14-
/ajax_datatables_rails
15-
1613
# RVM files
1714
/.ruby-version
1815

1916
# Gem files
2017
/*.gem
18+
19+
# Ignore dummy app files
20+
spec/dummy/db/*.sqlite3
21+
spec/dummy/db/*.sqlite3-journal
22+
spec/dummy/log/*.log
23+
spec/dummy/tmp/

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source 'https://rubygems.org'
44

55
gemspec
66

7-
gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
7+
gem 'appraisal', git: 'https://github.com/n-rodriguez/appraisal.git', branch: 'wip/combustion'

ajax-datatables-rails.gemspec

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ Gem::Specification.new do |s|
2323

2424
s.files = `git ls-files`.split("\n")
2525

26+
s.add_runtime_dependency 'rails', '>= 5.2'
2627
s.add_runtime_dependency 'zeitwerk'
2728

2829
s.add_development_dependency 'activerecord-oracle_enhanced-adapter'
2930
s.add_development_dependency 'appraisal'
31+
s.add_development_dependency 'combustion', '~> 1.3'
3032
s.add_development_dependency 'database_cleaner'
3133
s.add_development_dependency 'factory_bot'
3234
s.add_development_dependency 'faker'
3335
s.add_development_dependency 'generator_spec'
3436
s.add_development_dependency 'guard-rspec'
3537
s.add_development_dependency 'pg'
38+
s.add_development_dependency 'puma'
3639
s.add_development_dependency 'pry'
37-
s.add_development_dependency 'rails', '>= 5.2'
3840
s.add_development_dependency 'rake'
3941
s.add_development_dependency 'rspec'
4042
s.add_development_dependency 'rspec-retry'
4143
s.add_development_dependency 'rubocop'
4244
s.add_development_dependency 'simplecov'
45+
s.add_development_dependency 'sqlite3', '~> 1.4.0'
4346
end

bin/rackup

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rackup' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12+
13+
bundle_binstub = File.expand_path("bundle", __dir__)
14+
15+
if File.file?(bundle_binstub)
16+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
17+
load(bundle_binstub)
18+
else
19+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
end
22+
end
23+
24+
require "rubygems"
25+
require "bundler/setup"
26+
27+
load Gem.bin_path("rack", "rackup")

config.ru

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
Bundler.require :default, :development
4+
5+
Combustion.path = 'spec/dummy'
6+
Combustion.initialize! :all
7+
run Combustion::Application

gemfiles/rails_5.2.6.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
5+
gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
66
gem "rails", "5.2.6"
77

88
install_if -> { ENV["DB_ADAPTER"] == "sqlite3" } do

gemfiles/rails_6.0.4.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
5+
gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
66
gem "rails", "6.0.4"
77

88
install_if -> { ENV["DB_ADAPTER"] == "sqlite3" } do

gemfiles/rails_6.1.4.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
5+
gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
66
gem "rails", "6.1.4"
77

88
install_if -> { ENV["DB_ADAPTER"] == "sqlite3" } do

gemfiles/rails_7.0.1.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
5+
gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
66
gem "rails", "7.0.1"
77

88
install_if -> { ENV["DB_ADAPTER"] == "sqlite3" } do

spec/dummy/app/assets/config/manifest.js

Whitespace-only changes.

spec/dummy/config/database.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<% adapter = ENV.fetch('DB_ADAPTER', 'postgresql') %>
2+
test:
3+
adapter: <%= adapter %>
4+
database: ajax_datatables_rails
5+
encoding: utf8
6+
7+
<% if adapter == 'postgresql' %>
8+
host: '127.0.0.1'
9+
port: 5432
10+
username: 'postgres'
11+
password: 'postgres'
12+
<% elsif adapter == 'mysql2' %>
13+
host: '127.0.0.1'
14+
port: 3306
15+
username: 'root'
16+
password: 'root'
17+
<% elsif adapter == 'oracle_enhanced' %>
18+
host: '127.0.0.1/xe'
19+
username: <%= ENV.fetch('USER') %>
20+
password: <%= ENV.fetch('USER') %>
21+
database: 'xe'
22+
<% elsif adapter == 'sqlite3' %>
23+
# database: ':memory:'
24+
database: db/ajax_datatables_rails.sqlite3
25+
<% end %>

spec/dummy/config/routes.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
Rails.application.routes.draw do
4+
# Add your own routes here, or remove this file if you don't have need for it.
5+
end

spec/dummy/config/storage.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test:
2+
service: Disk
3+
root: /tmp/ajax-datatables-rails/tmp/storage
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
ActiveRecord::Schema.define do
4-
self.verbose = false
5-
64
create_table :users, force: true do |t|
75
t.string :username
86
t.string :email
@@ -12,5 +10,4 @@
1210

1311
t.timestamps null: false
1412
end
15-
1613
end

spec/dummy/log/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.log

spec/dummy/public/favicon.ico

Whitespace-only changes.

spec/spec_helper.rb

+5-27
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# frozen_string_literal: true
22

3+
require 'combustion'
4+
5+
Combustion.path = 'spec/dummy'
6+
Combustion.initialize! :active_record, :action_controller
7+
38
require 'simplecov'
49
require 'rspec'
510
require 'rspec/retry'
611
require 'database_cleaner'
712
require 'factory_bot'
813
require 'faker'
914
require 'pry'
10-
require 'rails'
11-
require 'active_record'
12-
require 'action_controller'
1315

1416
# Start Simplecov
1517
SimpleCov.start do
@@ -79,30 +81,6 @@ def self.postgresql?
7981
end
8082
end
8183

82-
# Configure ActiveRecord
83-
adapter = ENV.fetch('DB_ADAPTER', 'postgresql')
84-
ENV['DB_ADAPTER'] = adapter
85-
86-
options = {
87-
adapter: adapter,
88-
database: 'ajax_datatables_rails',
89-
encoding: 'utf8',
90-
}
91-
92-
options =
93-
case adapter
94-
when 'postgresql'
95-
options.merge(host: '127.0.0.1', port: 5432, username: 'postgres', password: 'postgres')
96-
when 'mysql2'
97-
options.merge(host: '127.0.0.1', port: 3306, username: 'root', password: 'root')
98-
when 'oracle_enhanced'
99-
options.merge(host: '127.0.0.1/xe', username: ENV['USER'], password: ENV['USER'], database: 'xe')
100-
when 'sqlite3'
101-
options.merge(database: ':memory:')
102-
end
103-
104-
ActiveRecord::Base.establish_connection(options)
105-
10684
# Require our gem
10785
require 'ajax-datatables-rails'
10886

0 commit comments

Comments
 (0)