schema_validations 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/prs.yml +134 -0
  3. data/.gitignore +1 -0
  4. data/.simplecov +20 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +5 -0
  7. data/README.md +15 -6
  8. data/Rakefile +2 -0
  9. data/gemfiles/Gemfile.base +1 -1
  10. data/gemfiles/activerecord-5.2/Gemfile.base +4 -0
  11. data/gemfiles/activerecord-5.2/Gemfile.mysql2 +10 -0
  12. data/gemfiles/activerecord-5.2/Gemfile.postgresql +10 -0
  13. data/gemfiles/{activerecord-5.1 → activerecord-5.2}/Gemfile.sqlite3 +3 -3
  14. data/gemfiles/activerecord-6.0/Gemfile.base +4 -0
  15. data/gemfiles/activerecord-6.0/Gemfile.mysql2 +10 -0
  16. data/gemfiles/activerecord-6.0/Gemfile.postgresql +10 -0
  17. data/gemfiles/{activerecord-5.0 → activerecord-6.0}/Gemfile.sqlite3 +3 -3
  18. data/init.rb +2 -0
  19. data/lib/schema_validations/active_record/type.rb +2 -0
  20. data/lib/schema_validations/active_record/validations.rb +2 -0
  21. data/lib/schema_validations/railtie.rb +2 -0
  22. data/lib/schema_validations/validators/not_nil_validator.rb +2 -0
  23. data/lib/schema_validations/version.rb +3 -1
  24. data/lib/schema_validations.rb +2 -0
  25. data/schema_dev.yml +5 -3
  26. data/schema_validations.gemspec +23 -27
  27. data/spec/spec_helper.rb +22 -18
  28. data/spec/support/active_model.rb +2 -0
  29. data/spec/validations_spec.rb +3 -1
  30. metadata +43 -94
  31. data/gemfiles/activerecord-5.0/Gemfile.base +0 -3
  32. data/gemfiles/activerecord-5.0/Gemfile.mysql2 +0 -10
  33. data/gemfiles/activerecord-5.0/Gemfile.postgresql +0 -10
  34. data/gemfiles/activerecord-5.1/Gemfile.base +0 -3
  35. data/gemfiles/activerecord-5.1/Gemfile.mysql2 +0 -10
  36. data/gemfiles/activerecord-5.1/Gemfile.postgresql +0 -10
  37. data/spec/schema_validations.sqlite3 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 08517658c327fcc14b2a8eecb1ea7fe539d930a8
4
- data.tar.gz: 1f5ce946a61da403f0cc19373c094d4e8c1f4c76
2
+ SHA256:
3
+ metadata.gz: 1b78d8982bebac58a973056eafde5936834ccca0d4c14d082ce4de1f077a9520
4
+ data.tar.gz: 929c35cc4a3d93b3442396ed13491b806c2d72915f2125bb16884e65ce4bca9c
5
5
  SHA512:
6
- metadata.gz: 6716d0a366f6f1ab1747997e283d40b5068d274408485c6ba0f89e54889f3a58131df86df54ba96b485261c8a03b87ed794821545358ae1490c001324f4187d0
7
- data.tar.gz: a35e99b160e8cf3f7925b8e962b91b0f0ceb9d2f39aeeca3cacf7b0a05b22d9525287f789d0e3344087efb2b45ec7f7fef0ef38225ec1d41c80aa29f41d3f8cf
6
+ metadata.gz: 10650e92299fcb0d86a864587f50f8337bdac03972d195d46eff628ea6de22323c0ef1d0272e840fd8383f8c032413b47eda302dd56bae8cf0163786b4646a69
7
+ data.tar.gz: 89b78874b3d66ee0fcde0818677aa6cd00cee09d375e9121e016209c64c40be11e4005cf37ea2694c74810326cc34fc0688236b4e8794fab8fed24cf85d248e2
@@ -0,0 +1,134 @@
1
+ # This file was auto-generated by the schema_dev tool, based on the data in
2
+ # ./schema_dev.yml
3
+ # Please do not edit this file; any changes will be overwritten next time
4
+ # schema_dev gets run.
5
+ ---
6
+ name: CI PR Builds
7
+ 'on':
8
+ push:
9
+ branches:
10
+ - master
11
+ pull_request:
12
+ concurrency:
13
+ group: ci-${{ github.ref }}
14
+ cancel-in-progress: true
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby:
22
+ - '2.5'
23
+ - '2.7'
24
+ - '3.0'
25
+ activerecord:
26
+ - '5.2'
27
+ - '6.0'
28
+ db:
29
+ - mysql2
30
+ - sqlite3
31
+ - skip
32
+ dbversion:
33
+ - skip
34
+ exclude:
35
+ - ruby: '3.0'
36
+ activerecord: '5.2'
37
+ - db: skip
38
+ dbversion: skip
39
+ include:
40
+ - ruby: '2.5'
41
+ activerecord: '5.2'
42
+ db: postgresql
43
+ dbversion: '9.6'
44
+ - ruby: '2.5'
45
+ activerecord: '6.0'
46
+ db: postgresql
47
+ dbversion: '9.6'
48
+ - ruby: '2.7'
49
+ activerecord: '5.2'
50
+ db: postgresql
51
+ dbversion: '9.6'
52
+ - ruby: '2.7'
53
+ activerecord: '6.0'
54
+ db: postgresql
55
+ dbversion: '9.6'
56
+ - ruby: '3.0'
57
+ activerecord: '6.0'
58
+ db: postgresql
59
+ dbversion: '9.6'
60
+ env:
61
+ BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
62
+ MYSQL_DB_HOST: 127.0.0.1
63
+ MYSQL_DB_USER: root
64
+ MYSQL_DB_PASS: database
65
+ POSTGRESQL_DB_HOST: 127.0.0.1
66
+ POSTGRESQL_DB_USER: schema_plus_test
67
+ POSTGRESQL_DB_PASS: database
68
+ steps:
69
+ - uses: actions/checkout@v2
70
+ - name: Set up Ruby
71
+ uses: ruby/setup-ruby@v1
72
+ with:
73
+ ruby-version: "${{ matrix.ruby }}"
74
+ bundler-cache: true
75
+ - name: Run bundle update
76
+ run: bundle update
77
+ - name: Start Mysql
78
+ if: matrix.db == 'mysql2'
79
+ run: |
80
+ docker run --rm --detach \
81
+ -e MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASS \
82
+ -p 3306:3306 \
83
+ --health-cmd "mysqladmin ping --host=127.0.0.1 --password=$MYSQL_DB_PASS --silent" \
84
+ --health-interval 5s \
85
+ --health-timeout 5s \
86
+ --health-retries 5 \
87
+ --name database mysql:5.6
88
+ - name: Start Postgresql
89
+ if: matrix.db == 'postgresql'
90
+ run: |
91
+ docker run --rm --detach \
92
+ -e POSTGRES_USER=$POSTGRESQL_DB_USER \
93
+ -e POSTGRES_PASSWORD=$POSTGRESQL_DB_PASS \
94
+ -p 5432:5432 \
95
+ --health-cmd "pg_isready -q" \
96
+ --health-interval 5s \
97
+ --health-timeout 5s \
98
+ --health-retries 5 \
99
+ --name database postgres:${{ matrix.dbversion }}
100
+ - name: Wait for database to start
101
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
102
+ run: |
103
+ COUNT=0
104
+ ATTEMPTS=20
105
+ until [[ $COUNT -eq $ATTEMPTS ]]; do
106
+ [ "$(docker inspect -f {{.State.Health.Status}} database)" == "healthy" ] && break
107
+ echo $(( COUNT++ )) > /dev/null
108
+ sleep 2
109
+ done
110
+ - name: Create testing database
111
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
112
+ run: bundle exec rake create_ci_database
113
+ - name: Run tests
114
+ run: bundle exec rake spec
115
+ - name: Shutdown database
116
+ if: always() && (matrix.db == 'postgresql' || matrix.db == 'mysql2')
117
+ run: docker stop database
118
+ - name: Coveralls Parallel
119
+ if: "${{ !env.ACT }}"
120
+ uses: coverallsapp/github-action@master
121
+ with:
122
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
123
+ flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}-${{ matrix.db }}-${{ matrix.dbversion }}
124
+ parallel: true
125
+ finish:
126
+ needs: test
127
+ runs-on: ubuntu-latest
128
+ steps:
129
+ - name: Coveralls Finished
130
+ if: "${{ !env.ACT }}"
131
+ uses: coverallsapp/github-action@master
132
+ with:
133
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
134
+ parallel-finished: true
data/.gitignore CHANGED
@@ -27,3 +27,4 @@ Gemfile.local
27
27
  Gemfile.lock
28
28
  gemfiles/*.lock
29
29
  gemfiles/**/*.lock
30
+ /.idea
data/.simplecov ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.configure do
4
+ enable_coverage :branch
5
+ add_filter '/spec/'
6
+
7
+ add_group 'Binaries', '/bin/'
8
+ add_group 'Libraries', '/lib/'
9
+
10
+ if ENV['CI']
11
+ require 'simplecov-lcov'
12
+
13
+ SimpleCov::Formatter::LcovFormatter.config do |c|
14
+ c.report_with_single_file = true
15
+ c.single_report_path = 'coverage/lcov.info'
16
+ end
17
+
18
+ formatter SimpleCov::Formatter::LcovFormatter
19
+ end
20
+ end
data/.travis.yml CHANGED
@@ -13,6 +13,9 @@ gemfile:
13
13
  - gemfiles/activerecord-5.1/Gemfile.mysql2
14
14
  - gemfiles/activerecord-5.1/Gemfile.postgresql
15
15
  - gemfiles/activerecord-5.1/Gemfile.sqlite3
16
+ - gemfiles/activerecord-5.2/Gemfile.mysql2
17
+ - gemfiles/activerecord-5.2/Gemfile.postgresql
18
+ - gemfiles/activerecord-5.2/Gemfile.sqlite3
16
19
  env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
17
20
  addons:
18
21
  postgresql: '9.4'
data/Gemfile CHANGED
@@ -1,3 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "http://rubygems.org"
2
4
 
3
5
  gemspec
6
+
7
+ gemfile_local = File.expand_path '../Gemfile.local', __FILE__
8
+ eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
data/README.md CHANGED
@@ -5,8 +5,8 @@ definitions simpler and more DRY, by automatically defining validations based
5
5
  on the database schema.
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/schema_validations.svg)](http://badge.fury.io/rb/schema_validations)
8
- [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_validations.svg)](http://travis-ci.org/SchemaPlus/schema_validations)
9
- [![Coverage Status](https://coveralls.io/repos/SchemaPlus/schema_validations/badge.svg?branch=master&service=github)](https://coveralls.io/github/SchemaPlus/schema_validations)
8
+ [![Build Status](https://github.com/SchemaPlus/schema_validations/actions/workflows/pr.yml/badge.svg)](http://github.com/SchemaPlus/schema_validations/actions)
9
+ [![Coverage Status](https://coveralls.io/github/SchemaPlus/schema_validations/badge.svg)](https://coveralls.io/github/SchemaPlus/schema_validations)
10
10
 
11
11
 
12
12
  ## Overview
@@ -174,8 +174,11 @@ As of version 1.2.0, SchemaValidations supports and is tested on:
174
174
 
175
175
  <!-- SCHEMA_DEV: MATRIX - begin -->
176
176
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
177
- * ruby **2.3.1** with activerecord **5.0**, using **mysql2**, **postgresql** or **sqlite3**
178
- * ruby **2.3.1** with activerecord **5.1**, using **mysql2**, **postgresql** or **sqlite3**
177
+ * ruby **2.5** with activerecord **5.2**, using **mysql2**, **postgresql:9.6** or **sqlite3**
178
+ * ruby **2.5** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
179
+ * ruby **2.7** with activerecord **5.2**, using **mysql2**, **postgresql:9.6** or **sqlite3**
180
+ * ruby **2.7** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
181
+ * ruby **3.0** with activerecord **6.0**, using **mysql2**, **postgresql:9.6** or **sqlite3**
179
182
 
180
183
  <!-- SCHEMA_DEV: MATRIX - end -->
181
184
 
@@ -187,6 +190,13 @@ Earlier versions of SchemaValidations supported:
187
190
 
188
191
  ## Release Notes
189
192
 
193
+ ### 2.4.0
194
+
195
+ * Add AR 6.0
196
+ * Add Ruby 3.0
197
+ * Remove support for AR < 5.2
198
+ * Remove support for Ruby < 2.5
199
+
190
200
  ### 2.3.0
191
201
 
192
202
  * Works with AR 5.1.
@@ -283,7 +293,7 @@ Some things to know about to help you develop and test:
283
293
  * **schema_dev**: SchemaValidations uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
284
294
  facilitate running rspec tests on the matrix of ruby, activerecord, and database
285
295
  versions that the gem supports, both locally and on
286
- [travis-ci](http://travis-ci.org/SchemaPlus/schema_validations)
296
+ [github actions](https://github.com/SchemaPlus/schema_validations/actions)
287
297
 
288
298
  To to run rspec locally on the full matrix, do:
289
299
 
@@ -295,7 +305,6 @@ Some things to know about to help you develop and test:
295
305
  The matrix of configurations is specified in `schema_dev.yml` in
296
306
  the project root.
297
307
 
298
-
299
308
  <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
300
309
 
301
310
  Code coverage results will be in coverage/index.html -- it should be at 100% coverage.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gemspec :path => File.expand_path('..', __FILE__)
2
+ gemspec path: File.expand_path('..', __FILE__)
3
3
 
4
4
  File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 5.2.0.beta0", "< 5.3"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
10
+ end
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.0", "< 6.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -1,5 +1,5 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
3
 
4
4
  platform :ruby do
5
5
  gem "sqlite3"
@@ -7,4 +7,4 @@ end
7
7
 
8
8
  platform :jruby do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
- end
10
+ end
data/init.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'schema_validations' unless defined?(SchemaValidations)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaValidations
2
4
  module ActiveRecord
3
5
  module Type
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaValidations
2
4
  module ActiveRecord
3
5
  module Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaValidations
2
4
  class Railtie < Rails::Railtie #:nodoc:
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaValidations
2
4
  module Validators
3
5
  # Validates that the field is not nil?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaValidations
2
- VERSION = "2.3.0"
4
+ VERSION = "2.4.0"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'valuable'
2
4
 
3
5
  require 'schema_plus_columns'
data/schema_dev.yml CHANGED
@@ -1,8 +1,10 @@
1
1
  ruby:
2
- - 2.3.1
2
+ - 2.5
3
+ - 2.7
4
+ - 3.0
3
5
  activerecord:
4
- - 5.0
5
- - 5.1
6
+ - 5.2
7
+ - 6.0
6
8
  db:
7
9
  - mysql2
8
10
  - postgresql
@@ -1,35 +1,31 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  $:.push File.expand_path("../lib", __FILE__)
3
4
  require "schema_validations/version"
4
5
 
5
- Gem::Specification.new do |s|
6
- s.name = "schema_validations"
7
- s.version = SchemaValidations::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Ronen Barzel", "Michał Łomnicki"]
10
- s.email = ["ronen@barzel.org", "michal.lomnicki@gmail.com"]
11
- s.homepage = "https://github.com/SchemaPlus/schema_validations"
12
- s.summary = "Automatically creates validations basing on the database schema."
13
- s.description = "SchemaValidations extends ActiveRecord to automatically create validations by inspecting the database schema. This makes your models more DRY as you no longer need to duplicate NOT NULL, unique, numeric and varchar constraints on the model level."
14
- s.license = 'MIT'
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "schema_validations"
8
+ gem.version = SchemaValidations::VERSION
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.authors = ["Ronen Barzel", "Michał Łomnicki"]
11
+ gem.email = ["ronen@barzel.org", "michal.lomnicki@gmail.com"]
12
+ gem.homepage = "https://github.com/SchemaPlus/schema_validations"
13
+ gem.summary = "Automatically creates validations basing on the database schema."
14
+ gem.description = "SchemaValidations extends ActiveRecord to automatically create validations by inspecting the database schema. This makes your models more DRY as you no longer need to duplicate NOT NULL, unique, numeric and varchar constraints on the model level."
15
+ gem.license = 'MIT'
15
16
 
16
- s.rubyforge_project = "schema_validations"
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ gem.require_paths = ["lib"]
17
21
 
18
- s.files = `git ls-files`.split("\n")
19
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
- s.require_paths = ["lib"]
22
+ gem.required_ruby_version = '>= 2.5'
22
23
 
23
- s.add_dependency("schema_plus_columns")
24
- s.add_dependency("activerecord", "~> 5.0")
25
- s.add_dependency("valuable")
24
+ gem.add_dependency 'schema_plus_columns', '~> 1.0.0'
25
+ gem.add_dependency 'activerecord', '>= 5.2', '< 6.1'
26
+ gem.add_dependency 'valuable'
26
27
 
27
- s.add_development_dependency("schema_dev", "~> 3.6")
28
- s.add_development_dependency("rake")
29
- s.add_development_dependency("rdoc")
30
- s.add_development_dependency("rspec")
31
- s.add_development_dependency("simplecov")
32
- s.add_development_dependency("simplecov-gem-profile")
33
- s.add_development_dependency("database_cleaner")
28
+ gem.add_development_dependency 'rake', '~> 13.0'
29
+ gem.add_development_dependency 'rspec', '~> 3.0'
30
+ gem.add_development_dependency 'schema_dev', '~> 4.1'
34
31
  end
35
-
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
- require 'simplecov-gem-profile'
3
- SimpleCov.start "gem"
4
+ SimpleCov.start
4
5
 
5
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -9,26 +10,19 @@ require 'rspec'
9
10
  require 'active_record'
10
11
  require 'schema_validations'
11
12
  require 'schema_dev/rspec'
12
- require 'database_cleaner'
13
- DatabaseCleaner.strategy = :truncation
14
13
 
15
14
  SchemaDev::Rspec.setup
16
15
 
17
16
  RSpec.configure do |config|
18
17
  config.around(:each) do |example|
19
- DatabaseCleaner.clean
20
18
  remove_all_models
21
19
 
22
- class ActiveRecord::InternalMetadata
23
- def self.create_table
24
- end
25
-
26
- def self.[]=(first, second)
27
- end
28
- end
29
-
30
20
  ActiveRecord::Migration.suppress_messages do
31
21
  example.run
22
+ ensure
23
+ ActiveRecord::Base.connection.tables.each do |table|
24
+ ActiveRecord::Migration.drop_table table, force: :cascade
25
+ end
32
26
  end
33
27
  end
34
28
  end
@@ -36,15 +30,25 @@ end
36
30
  # avoid deprecation warnings
37
31
  I18n.enforce_available_locales = true
38
32
 
39
- Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
33
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
40
34
 
41
35
  def remove_all_models
42
- ObjectSpace.each_object(Class) do |c|
43
- next unless c.ancestors.include? ActiveRecord::Base
44
- next if c == ActiveRecord::Base
45
- next if c.name.blank?
36
+ ActiveRecord::Base.descendants.each do |c|
37
+ next if c == ActiveRecord::InternalMetadata
38
+ next if c == ActiveRecord::SchemaMigration
46
39
  ActiveSupport::Dependencies.remove_constant c.name
47
40
  end
48
41
  end
49
42
 
43
+ def define_schema(config={}, &block)
44
+ ActiveRecord::Migration.suppress_messages do
45
+ ActiveRecord::Schema.define do
46
+ connection.tables.each do |table|
47
+ drop_table table, force: :cascade
48
+ end
49
+ instance_eval &block
50
+ end
51
+ end
52
+ end
53
+
50
54
  SimpleCov.command_name "[Ruby #{RUBY_VERSION} - ActiveRecord #{::ActiveRecord::VERSION::STRING}]"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # ported from rspec-rails
2
4
  # There is no reason to install whole gem as we
3
5
  # need only that tiny helper
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
4
 
3
5
  describe "Validations" do
4
6
 
5
7
  before(:each) do
6
- ActiveRecord::Schema.define do
8
+ define_schema do
7
9
 
8
10
  create_table :articles, force: true do |t|
9
11
  t.string :title, limit: 50
metadata CHANGED
@@ -1,80 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronen Barzel
8
8
  - Michał Łomnicki
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-24 00:00:00.000000000 Z
12
+ date: 2022-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: schema_plus_columns
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: activerecord
30
16
  requirement: !ruby/object:Gem::Requirement
31
17
  requirements:
32
18
  - - "~>"
33
19
  - !ruby/object:Gem::Version
34
- version: '5.0'
20
+ version: 1.0.0
35
21
  type: :runtime
36
22
  prerelease: false
37
23
  version_requirements: !ruby/object:Gem::Requirement
38
24
  requirements:
39
25
  - - "~>"
40
26
  - !ruby/object:Gem::Version
41
- version: '5.0'
27
+ version: 1.0.0
42
28
  - !ruby/object:Gem::Dependency
43
- name: valuable
29
+ name: activerecord
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
32
  - - ">="
47
33
  - !ruby/object:Gem::Version
48
- version: '0'
34
+ version: '5.2'
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '6.1'
49
38
  type: :runtime
50
39
  prerelease: false
51
40
  version_requirements: !ruby/object:Gem::Requirement
52
41
  requirements:
53
42
  - - ">="
54
43
  - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: schema_dev
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '3.6'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
44
+ version: '5.2'
45
+ - - "<"
68
46
  - !ruby/object:Gem::Version
69
- version: '3.6'
47
+ version: '6.1'
70
48
  - !ruby/object:Gem::Dependency
71
- name: rake
49
+ name: valuable
72
50
  requirement: !ruby/object:Gem::Requirement
73
51
  requirements:
74
52
  - - ">="
75
53
  - !ruby/object:Gem::Version
76
54
  version: '0'
77
- type: :development
55
+ type: :runtime
78
56
  prerelease: false
79
57
  version_requirements: !ruby/object:Gem::Requirement
80
58
  requirements:
@@ -82,75 +60,47 @@ dependencies:
82
60
  - !ruby/object:Gem::Version
83
61
  version: '0'
84
62
  - !ruby/object:Gem::Dependency
85
- name: rdoc
63
+ name: rake
86
64
  requirement: !ruby/object:Gem::Requirement
87
65
  requirements:
88
- - - ">="
66
+ - - "~>"
89
67
  - !ruby/object:Gem::Version
90
- version: '0'
68
+ version: '13.0'
91
69
  type: :development
92
70
  prerelease: false
93
71
  version_requirements: !ruby/object:Gem::Requirement
94
72
  requirements:
95
- - - ">="
73
+ - - "~>"
96
74
  - !ruby/object:Gem::Version
97
- version: '0'
75
+ version: '13.0'
98
76
  - !ruby/object:Gem::Dependency
99
77
  name: rspec
100
78
  requirement: !ruby/object:Gem::Requirement
101
79
  requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: simplecov
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: simplecov-gem-profile
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
80
+ - - "~>"
131
81
  - !ruby/object:Gem::Version
132
- version: '0'
82
+ version: '3.0'
133
83
  type: :development
134
84
  prerelease: false
135
85
  version_requirements: !ruby/object:Gem::Requirement
136
86
  requirements:
137
- - - ">="
87
+ - - "~>"
138
88
  - !ruby/object:Gem::Version
139
- version: '0'
89
+ version: '3.0'
140
90
  - !ruby/object:Gem::Dependency
141
- name: database_cleaner
91
+ name: schema_dev
142
92
  requirement: !ruby/object:Gem::Requirement
143
93
  requirements:
144
- - - ">="
94
+ - - "~>"
145
95
  - !ruby/object:Gem::Version
146
- version: '0'
96
+ version: '4.1'
147
97
  type: :development
148
98
  prerelease: false
149
99
  version_requirements: !ruby/object:Gem::Requirement
150
100
  requirements:
151
- - - ">="
101
+ - - "~>"
152
102
  - !ruby/object:Gem::Version
153
- version: '0'
103
+ version: '4.1'
154
104
  description: SchemaValidations extends ActiveRecord to automatically create validations
155
105
  by inspecting the database schema. This makes your models more DRY as you no longer
156
106
  need to duplicate NOT NULL, unique, numeric and varchar constraints on the model
@@ -162,21 +112,23 @@ executables: []
162
112
  extensions: []
163
113
  extra_rdoc_files: []
164
114
  files:
115
+ - ".github/workflows/prs.yml"
165
116
  - ".gitignore"
117
+ - ".simplecov"
166
118
  - ".travis.yml"
167
119
  - Gemfile
168
120
  - MIT-LICENSE
169
121
  - README.md
170
122
  - Rakefile
171
123
  - gemfiles/Gemfile.base
172
- - gemfiles/activerecord-5.0/Gemfile.base
173
- - gemfiles/activerecord-5.0/Gemfile.mysql2
174
- - gemfiles/activerecord-5.0/Gemfile.postgresql
175
- - gemfiles/activerecord-5.0/Gemfile.sqlite3
176
- - gemfiles/activerecord-5.1/Gemfile.base
177
- - gemfiles/activerecord-5.1/Gemfile.mysql2
178
- - gemfiles/activerecord-5.1/Gemfile.postgresql
179
- - gemfiles/activerecord-5.1/Gemfile.sqlite3
124
+ - gemfiles/activerecord-5.2/Gemfile.base
125
+ - gemfiles/activerecord-5.2/Gemfile.mysql2
126
+ - gemfiles/activerecord-5.2/Gemfile.postgresql
127
+ - gemfiles/activerecord-5.2/Gemfile.sqlite3
128
+ - gemfiles/activerecord-6.0/Gemfile.base
129
+ - gemfiles/activerecord-6.0/Gemfile.mysql2
130
+ - gemfiles/activerecord-6.0/Gemfile.postgresql
131
+ - gemfiles/activerecord-6.0/Gemfile.sqlite3
180
132
  - init.rb
181
133
  - lib/schema_validations.rb
182
134
  - lib/schema_validations/active_record/type.rb
@@ -186,7 +138,6 @@ files:
186
138
  - lib/schema_validations/version.rb
187
139
  - schema_dev.yml
188
140
  - schema_validations.gemspec
189
- - spec/schema_validations.sqlite3
190
141
  - spec/spec_helper.rb
191
142
  - spec/support/active_model.rb
192
143
  - spec/validations_spec.rb
@@ -194,7 +145,7 @@ homepage: https://github.com/SchemaPlus/schema_validations
194
145
  licenses:
195
146
  - MIT
196
147
  metadata: {}
197
- post_install_message:
148
+ post_install_message:
198
149
  rdoc_options: []
199
150
  require_paths:
200
151
  - lib
@@ -202,20 +153,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
153
  requirements:
203
154
  - - ">="
204
155
  - !ruby/object:Gem::Version
205
- version: '0'
156
+ version: '2.5'
206
157
  required_rubygems_version: !ruby/object:Gem::Requirement
207
158
  requirements:
208
159
  - - ">="
209
160
  - !ruby/object:Gem::Version
210
161
  version: '0'
211
162
  requirements: []
212
- rubyforge_project: schema_validations
213
- rubygems_version: 2.5.1
214
- signing_key:
163
+ rubygems_version: 3.0.8
164
+ signing_key:
215
165
  specification_version: 4
216
166
  summary: Automatically creates validations basing on the database schema.
217
167
  test_files:
218
- - spec/schema_validations.sqlite3
219
168
  - spec/spec_helper.rb
220
169
  - spec/support/active_model.rb
221
170
  - spec/validations_spec.rb
@@ -1,3 +0,0 @@
1
- eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
-
3
- gem "activerecord", "~> 5.0.1"
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "mysql2"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcmysql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "pg"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcpostgresql-adapter'
10
- end
@@ -1,3 +0,0 @@
1
- eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
-
3
- gem "activerecord", "~> 5.1.0"
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "mysql2"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcmysql-adapter'
10
- end
@@ -1,10 +0,0 @@
1
- require "pathname"
2
- eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
-
4
- platform :ruby do
5
- gem "pg"
6
- end
7
-
8
- platform :jruby do
9
- gem 'activerecord-jdbcpostgresql-adapter'
10
- end
Binary file