with_model 2.1.2 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +61 -0
- data/.jrubyrc +1 -0
- data/.rubocop.yml +28 -4
- data/.rubocop_todo.yml +78 -0
- data/CHANGELOG.md +21 -1
- data/Gemfile +11 -4
- data/LICENSE +1 -1
- data/README.md +14 -12
- data/Rakefile +12 -2
- data/lib/with_model/model/dsl.rb +1 -1
- data/lib/with_model/model.rb +14 -6
- data/lib/with_model/table.rb +2 -2
- data/lib/with_model/version.rb +1 -1
- data/lib/with_model.rb +40 -17
- data/spec/.rubocop.yml +5 -0
- data/spec/active_record_behaviors_spec.rb +1 -0
- data/spec/readme_spec.rb +3 -4
- data/spec/spec_helper.rb +12 -6
- data/spec/with_model_spec.rb +39 -21
- data/test/test_helper.rb +28 -0
- data/test/with_model_test.rb +39 -0
- data/with_model.gemspec +13 -5
- metadata +126 -26
- data/.travis.yml +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6da93806455c916606077722ee10e9e5f0fd4ec785471288d210949b3891507
|
4
|
+
data.tar.gz: dad3a97b161ccb4d1256402eb7ebffd6746db155094dbd2341e2d860428f9437
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f83311c48f5472bd2e3f0d00ddb58fedd14de54d483c06ac1594fdfb26c7344174eb92e3dd28593a4b99b582b5872f3a92941a681a2116e244625f18fa4759d
|
7
|
+
data.tar.gz: fc9044c0f5e92d9ec0351d3ce912df3cdc3bc4aeddb238ec7d1258f6e63620c3caaaaa65ebf79ce639c2fa9aea2dcb44b098fa57b421d96483e825ad047ae57f
|
@@ -0,0 +1,61 @@
|
|
1
|
+
name: build
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- github-actions
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- master
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
env:
|
16
|
+
CI: true
|
17
|
+
strategy:
|
18
|
+
fail-fast: false
|
19
|
+
matrix:
|
20
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
21
|
+
active-record-version-env:
|
22
|
+
- ACTIVE_RECORD_VERSION="~> 5.2.0"
|
23
|
+
- ACTIVE_RECORD_VERSION="~> 6.0.0"
|
24
|
+
- ACTIVE_RECORD_VERSION="~> 6.1.0"
|
25
|
+
- ACTIVE_RECORD_VERSION="~> 7.0.0"
|
26
|
+
allow-failure: [false]
|
27
|
+
include:
|
28
|
+
- ruby-version: '3.1'
|
29
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 7.0.0"
|
30
|
+
allow-failure: true
|
31
|
+
- ruby-version: '3.1'
|
32
|
+
active-record-version-env: ACTIVE_RECORD_BRANCH="7-0-stable"
|
33
|
+
allow-failure: true
|
34
|
+
- ruby-version: '3.1'
|
35
|
+
active-record-version-env: ACTIVE_RECORD_BRANCH="6-1-stable"
|
36
|
+
allow-failure: true
|
37
|
+
exclude:
|
38
|
+
- ruby-version: '3.0'
|
39
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
|
40
|
+
allow-failure: false
|
41
|
+
- ruby-version: '3.1'
|
42
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
|
43
|
+
allow-failure: false
|
44
|
+
- ruby-version: '2.6'
|
45
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 7.0.0"
|
46
|
+
allow-failure: false
|
47
|
+
- ruby-version: '3.1'
|
48
|
+
active-record-version-env: ACTIVE_RECORD_VERSION="~> 7.0.0"
|
49
|
+
allow-failure: false
|
50
|
+
continue-on-error: ${{ matrix.allow-failure }}
|
51
|
+
steps:
|
52
|
+
- uses: actions/checkout@v2
|
53
|
+
- name: Set up Ruby
|
54
|
+
uses: ruby/setup-ruby@v1
|
55
|
+
with:
|
56
|
+
ruby-version: ${{ matrix.ruby-version }}
|
57
|
+
bundler-cache: true
|
58
|
+
- name: Update bundle
|
59
|
+
run: ${{ matrix.active-record-version-env }} bundle update
|
60
|
+
- name: Run tests
|
61
|
+
run: ${{ matrix.active-record-version-env }} bundle exec rake
|
data/.jrubyrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
debug.fullTrace=true
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
require:
|
4
|
+
- rubocop-rake
|
5
|
+
- rubocop-rspec
|
6
|
+
- rubocop-minitest
|
4
7
|
|
5
8
|
AllCops:
|
6
|
-
|
9
|
+
NewCops: enable
|
10
|
+
TargetRubyVersion: 2.6
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- 'spec/**/*'
|
15
|
+
- 'with_model.gemspec'
|
16
|
+
|
17
|
+
Bundler/OrderedGems:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Bundler/DuplicatedGem:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
RSpec/Be:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
RSpec/BeforeAfterAll:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/Documentation:
|
30
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-11-22 01:30:26 UTC using RuboCop version 1.3.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 6
|
10
|
+
# Configuration parameters: Prefixes.
|
11
|
+
# Prefixes: when, with, without
|
12
|
+
RSpec/ContextWording:
|
13
|
+
Exclude:
|
14
|
+
- 'spec/active_record_behaviors_spec.rb'
|
15
|
+
- 'spec/with_model_spec.rb'
|
16
|
+
|
17
|
+
# Offense count: 6
|
18
|
+
# Configuration parameters: IgnoredMetadata.
|
19
|
+
RSpec/DescribeClass:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/active_record_behaviors_spec.rb'
|
22
|
+
- 'spec/readme_spec.rb'
|
23
|
+
- 'spec/with_model_spec.rb'
|
24
|
+
|
25
|
+
# Offense count: 5
|
26
|
+
# Configuration parameters: Max.
|
27
|
+
RSpec/ExampleLength:
|
28
|
+
Exclude:
|
29
|
+
- 'spec/active_record_behaviors_spec.rb'
|
30
|
+
- 'spec/readme_spec.rb'
|
31
|
+
- 'spec/with_model_spec.rb'
|
32
|
+
|
33
|
+
# Offense count: 7
|
34
|
+
# Configuration parameters: AssignmentOnly.
|
35
|
+
RSpec/InstanceVariable:
|
36
|
+
Exclude:
|
37
|
+
- 'spec/active_record_behaviors_spec.rb'
|
38
|
+
|
39
|
+
# Offense count: 2
|
40
|
+
RSpec/LeakyConstantDeclaration:
|
41
|
+
Exclude:
|
42
|
+
- 'spec/readme_spec.rb'
|
43
|
+
- 'spec/with_model_spec.rb'
|
44
|
+
|
45
|
+
# Offense count: 2
|
46
|
+
# Configuration parameters: .
|
47
|
+
# SupportedStyles: have_received, receive
|
48
|
+
RSpec/MessageSpies:
|
49
|
+
EnforcedStyle: receive
|
50
|
+
|
51
|
+
# Offense count: 1
|
52
|
+
RSpec/MultipleDescribes:
|
53
|
+
Exclude:
|
54
|
+
- 'spec/readme_spec.rb'
|
55
|
+
|
56
|
+
# Offense count: 13
|
57
|
+
RSpec/MultipleExpectations:
|
58
|
+
Max: 5
|
59
|
+
|
60
|
+
# Offense count: 4
|
61
|
+
# Configuration parameters: IgnoreSharedExamples.
|
62
|
+
RSpec/NamedSubject:
|
63
|
+
Exclude:
|
64
|
+
- 'spec/with_model_spec.rb'
|
65
|
+
|
66
|
+
# Offense count: 2
|
67
|
+
RSpec/NestedGroups:
|
68
|
+
Max: 4
|
69
|
+
|
70
|
+
# Offense count: 4
|
71
|
+
RSpec/RepeatedExample:
|
72
|
+
Exclude:
|
73
|
+
- 'spec/with_model_spec.rb'
|
74
|
+
|
75
|
+
# Offense count: 2
|
76
|
+
RSpec/SubjectStub:
|
77
|
+
Exclude:
|
78
|
+
- 'spec/with_model_spec.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,24 @@
|
|
1
|
-
### 2.
|
1
|
+
### 2.1.6
|
2
|
+
- Require Ruby 2.6 or later
|
3
|
+
- Add Ruby 3.0 and 3.1 support
|
4
|
+
- Add Active Record 6.1 and 7.0 support
|
5
|
+
- Add minitest support (Miks Miķelsons)
|
6
|
+
|
7
|
+
### 2.1.5
|
8
|
+
|
9
|
+
- Add support for Active Record 6.1
|
10
|
+
|
11
|
+
### 2.1.4
|
12
|
+
|
13
|
+
- Remove deprecation warnings for Ruby 2.7
|
14
|
+
- Require Ruby 2.4 or later
|
15
|
+
- Require Active Record 5.2 or later
|
16
|
+
|
17
|
+
### 2.1.3
|
18
|
+
|
19
|
+
- Support ActiveRecord 6.0, working around new dependency tracking API
|
20
|
+
|
21
|
+
### 2.1.2
|
2
22
|
|
3
23
|
- Don't clobber existing rake executable
|
4
24
|
|
data/Gemfile
CHANGED
@@ -4,14 +4,21 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem 'lint-config-ruby', git: 'https://github.com/Casecommons/lint-config-ruby.git', tag: 'v1.0.0'
|
8
|
-
|
9
7
|
ar_branch = ENV['ACTIVE_RECORD_BRANCH']
|
10
8
|
ar_version = ENV['ACTIVE_RECORD_VERSION']
|
9
|
+
is_jruby = RUBY_PLATFORM == 'java'
|
11
10
|
|
12
11
|
if ar_branch
|
13
12
|
gem 'activerecord', git: 'https://github.com/rails/rails.git', branch: ar_branch
|
14
|
-
|
13
|
+
if ar_branch == 'master'
|
14
|
+
gem 'arel', git: 'https://github.com/rails/arel.git'
|
15
|
+
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git' if is_jruby
|
16
|
+
end
|
15
17
|
elsif ar_version
|
16
|
-
gem 'activerecord', ar_version
|
18
|
+
gem 'activerecord', ar_version
|
19
|
+
if is_jruby && !Gem::Requirement.new(ar_version).satisfied_by?(Gem::Version.new('5.2.0'))
|
20
|
+
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git'
|
21
|
+
end
|
17
22
|
end
|
23
|
+
|
24
|
+
gem 'sqlite3', '~> 1.4.1' unless is_jruby
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010
|
1
|
+
Copyright (c) 2010–2022 Casebook, PBC <http://www.casebook.net>
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# [with_model](https://github.com/Casecommons/with_model)
|
2
2
|
|
3
3
|
[![Gem Version](https://img.shields.io/gem/v/with_model.svg?style=flat)](https://rubygems.org/gems/with_model)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/Casecommons/with_model/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Casecommons/with_model/actions/workflows/ci.yml)
|
5
5
|
[![API Documentation](https://img.shields.io/badge/yard-api%20docs-lightgrey.svg)](https://www.rubydoc.info/gems/with_model)
|
6
6
|
|
7
|
-
`with_model` dynamically builds an
|
7
|
+
`with_model` dynamically builds an Active Record model (with table) before each test in a group and destroys it afterwards.
|
8
8
|
|
9
9
|
## Development status
|
10
10
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
Install as usual: `gem install with_model` or add `gem 'with_model'` to your Gemfile. See `.
|
15
|
+
Install as usual: `gem install with_model` or add `gem 'with_model'` to your Gemfile. See [`.github/workflows/ci.yml`](./.github/workflows/ci.yml) for supported (tested) Ruby versions.
|
16
16
|
|
17
17
|
### RSpec
|
18
18
|
|
@@ -28,11 +28,13 @@ end
|
|
28
28
|
|
29
29
|
### minitest/spec
|
30
30
|
|
31
|
-
Extend `WithModel` into minitest/spec:
|
31
|
+
Extend `WithModel` into minitest/spec and set the test runner explicitly:
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
require 'with_model'
|
35
35
|
|
36
|
+
WithModel.runner = :minitest
|
37
|
+
|
36
38
|
class Minitest::Spec
|
37
39
|
extend WithModel
|
38
40
|
end
|
@@ -49,13 +51,13 @@ describe "A blog post" do
|
|
49
51
|
module MyModule; end
|
50
52
|
|
51
53
|
with_model :BlogPost do
|
52
|
-
# The table block (and an options hash) is passed to
|
54
|
+
# The table block (and an options hash) is passed to Active Record migration’s `create_table`.
|
53
55
|
table do |t|
|
54
56
|
t.string :title
|
55
57
|
t.timestamps null: false
|
56
58
|
end
|
57
59
|
|
58
|
-
# The model block is the
|
60
|
+
# The model block is the Active Record model’s class body.
|
59
61
|
model do
|
60
62
|
include MyModule
|
61
63
|
has_many :comments
|
@@ -102,7 +104,7 @@ describe "A blog post" do
|
|
102
104
|
|
103
105
|
it "can do all the things a regular model can" do
|
104
106
|
record = BlogPost.new
|
105
|
-
expect(record).
|
107
|
+
expect(record).not_to be_valid
|
106
108
|
record.title = "foo"
|
107
109
|
expect(record).to be_valid
|
108
110
|
expect(record.save).to eq true
|
@@ -155,7 +157,7 @@ describe "with table options" do
|
|
155
157
|
end
|
156
158
|
|
157
159
|
it "respects the additional options" do
|
158
|
-
expect(WithOptions.columns.map(&:name)).
|
160
|
+
expect(WithOptions.columns.map(&:name)).not_to include("id")
|
159
161
|
end
|
160
162
|
end
|
161
163
|
```
|
@@ -169,9 +171,9 @@ See the [gemspec metadata](https://rubygems.org/gems/with_model) for dependency
|
|
169
171
|
- A unique table name is used for tables generated via `with_model`/`WithModel::Model.new`. This allows `with_model` (when limited to this API) to run concurrently (in processes or threads) with a single database schema. While there is a possibility of collision, it is very small.
|
170
172
|
- A user-supplied table name is used for tables generated via `with_table`/`WithModel::Table.new`. This may cause collisions at runtime if tests are run concurrently against a single database schema, unless the caller takes care to ensure the table names passed as arguments are unique across threads/processes.
|
171
173
|
- Generated models are created in stubbed constants, which are global; no guarantee is made to the uniqueness of a constant, and this may be unsafe.
|
172
|
-
- Generated classes are
|
173
|
-
- This library makes no guarantee
|
174
|
-
- This library makes no guarantee
|
174
|
+
- Generated classes are Active Record subclasses:
|
175
|
+
- This library makes no guarantee as to the thread-safety of creating Active Record subclasses concurrently.
|
176
|
+
- This library makes no guarantee as to the thread-safety of cleaning up Active Record/Active Support’s internals which are polluted upon class creation.
|
175
177
|
|
176
178
|
In general, `with_model` is not guaranteed to be thread-safe, but is, in certain usages, safe to use concurrently across multiple processes with a single database schema.
|
177
179
|
|
@@ -181,5 +183,5 @@ In general, `with_model` is not guaranteed to be thread-safe, but is, in certain
|
|
181
183
|
|
182
184
|
## License
|
183
185
|
|
184
|
-
Copyright © 2010–
|
186
|
+
Copyright © 2010–2022 [Casebook PBC](https://www.casebook.net).
|
185
187
|
Licensed under the MIT license, see [LICENSE](/LICENSE) file.
|
data/Rakefile
CHANGED
@@ -2,10 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rake/testtask'
|
5
6
|
require 'rubocop/rake_task'
|
6
7
|
|
7
8
|
desc 'Run specs'
|
8
|
-
RSpec::Core::RakeTask.new
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.pattern = Dir.glob('spec/**/*_spec.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Run tests'
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'test'
|
16
|
+
t.libs << 'lib'
|
17
|
+
t.pattern = 'test/**/*_test.rb'
|
18
|
+
end
|
9
19
|
|
10
20
|
desc 'Run lint'
|
11
21
|
RuboCop::RakeTask.new
|
@@ -17,4 +27,4 @@ namespace 'doc' do
|
|
17
27
|
end
|
18
28
|
end
|
19
29
|
|
20
|
-
task default: %i[spec rubocop]
|
30
|
+
task default: %i[spec test rubocop]
|
data/lib/with_model/model/dsl.rb
CHANGED
@@ -8,7 +8,7 @@ module WithModel
|
|
8
8
|
@model = model
|
9
9
|
end
|
10
10
|
|
11
|
-
# Provide a schema definition for the table, passed to ActiveRecord
|
11
|
+
# Provide a schema definition for the table, passed to ActiveRecord's `create_table`.
|
12
12
|
# The table name will be auto-generated.
|
13
13
|
#
|
14
14
|
# @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_table
|
data/lib/with_model/model.rb
CHANGED
@@ -13,8 +13,8 @@ module WithModel
|
|
13
13
|
class Model
|
14
14
|
attr_writer :model_block, :table_block, :table_options
|
15
15
|
|
16
|
-
# @param name The constant name
|
17
|
-
# @param superclass The superclass for the created class. Should
|
16
|
+
# @param [Symbol] name The constant name to assign the model class to.
|
17
|
+
# @param [Class] superclass The superclass for the created class. Should
|
18
18
|
# have `ActiveRecord::Base` as an ancestor.
|
19
19
|
def initialize(name, superclass: ActiveRecord::Base)
|
20
20
|
@name = name.to_sym
|
@@ -35,7 +35,7 @@ module WithModel
|
|
35
35
|
|
36
36
|
def destroy
|
37
37
|
stubber.unstub_const
|
38
|
-
|
38
|
+
cleanup_descendants_tracking
|
39
39
|
reset_dependencies_cache
|
40
40
|
table.destroy
|
41
41
|
@model = nil
|
@@ -53,13 +53,21 @@ module WithModel
|
|
53
53
|
@model.reset_column_information
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
56
|
+
def cleanup_descendants_tracking
|
57
|
+
if defined?(ActiveSupport::DescendantsTracker)
|
58
|
+
if ActiveSupport::VERSION::MAJOR >= 7
|
59
|
+
ActiveSupport::DescendantsTracker.clear([ActiveRecord::Base])
|
60
|
+
else
|
61
|
+
ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants).delete(ActiveRecord::Base)
|
62
|
+
end
|
63
|
+
elsif @model.superclass.respond_to?(:direct_descendants)
|
64
|
+
@model.superclass.direct_descendants.delete(@model)
|
65
|
+
end
|
59
66
|
end
|
60
67
|
|
61
68
|
def reset_dependencies_cache
|
62
69
|
return unless defined?(ActiveSupport::Dependencies::Reference)
|
70
|
+
|
63
71
|
ActiveSupport::Dependencies::Reference.clear!
|
64
72
|
end
|
65
73
|
|
data/lib/with_model/table.rb
CHANGED
@@ -6,7 +6,7 @@ module WithModel
|
|
6
6
|
# In general, direct use of this class should be avoided. Instead use
|
7
7
|
# either the {WithModel high-level API} or {WithModel::Model::DSL low-level API}.
|
8
8
|
class Table
|
9
|
-
# @param name The name of the table to create.
|
9
|
+
# @param [Symbol] name The name of the table to create.
|
10
10
|
# @param options Passed to ActiveRecord `create_table`.
|
11
11
|
# @param block Passed to ActiveRecord `create_table`.
|
12
12
|
# @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_table
|
@@ -20,7 +20,7 @@ module WithModel
|
|
20
20
|
# it already exists.
|
21
21
|
def create
|
22
22
|
connection.drop_table(@name) if exists?
|
23
|
-
connection.create_table(@name,
|
23
|
+
connection.create_table(@name, **@options, &@block)
|
24
24
|
end
|
25
25
|
|
26
26
|
def destroy
|
data/lib/with_model/version.rb
CHANGED
data/lib/with_model.rb
CHANGED
@@ -6,37 +6,60 @@ require 'with_model/table'
|
|
6
6
|
require 'with_model/version'
|
7
7
|
|
8
8
|
module WithModel
|
9
|
-
|
10
|
-
|
9
|
+
class << self
|
10
|
+
attr_writer :runner
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.runner
|
14
|
+
@runner ||= :rspec
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param [Symbol] name The constant name to assign the model class to.
|
18
|
+
# @param scope Passed to `before`/`after` in the test context. RSpec only.
|
11
19
|
# @param options Passed to {WithModel::Model#initialize}.
|
12
20
|
# @param block Yielded an instance of {WithModel::Model::DSL}.
|
13
21
|
def with_model(name, scope: nil, **options, &block)
|
14
|
-
|
22
|
+
runner = options.delete(:runner)
|
23
|
+
model = Model.new name, **options
|
15
24
|
dsl = Model::DSL.new model
|
16
25
|
dsl.instance_exec(&block) if block
|
17
26
|
|
18
|
-
|
19
|
-
model.create
|
20
|
-
end
|
21
|
-
|
22
|
-
after(*scope) do
|
23
|
-
model.destroy
|
24
|
-
end
|
27
|
+
setup_object(model, scope: scope, runner: runner)
|
25
28
|
end
|
26
29
|
|
27
|
-
# @param name The table name
|
28
|
-
# @param scope Passed to `before`/`after` in the test context.
|
30
|
+
# @param [Symbol] name The table name to create.
|
31
|
+
# @param scope Passed to `before`/`after` in the test context. Rspec only.
|
29
32
|
# @param options Passed to {WithModel::Table#initialize}.
|
30
33
|
# @param block Passed to {WithModel::Table#initialize} (like {WithModel::Model::DSL#table}).
|
31
34
|
def with_table(name, scope: nil, **options, &block)
|
35
|
+
runner = options.delete(:runner)
|
32
36
|
table = Table.new name, options, &block
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
setup_object(table, scope: scope, runner: runner)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# @param [Object] object The new model object instance to create
|
44
|
+
# @param scope Passed to `before`/`after` in the test context. Rspec only.
|
45
|
+
def setup_object(object, scope: nil, runner: nil) # rubocop:disable Metrics/MethodLength
|
46
|
+
case runner || WithModel.runner
|
47
|
+
when :rspec
|
48
|
+
before(*scope) do
|
49
|
+
object.create
|
50
|
+
end
|
51
|
+
|
52
|
+
after(*scope) do
|
53
|
+
object.destroy
|
54
|
+
end
|
55
|
+
when :minitest
|
56
|
+
object.create
|
37
57
|
|
38
|
-
|
39
|
-
|
58
|
+
Minitest.after_run do
|
59
|
+
object.destroy
|
60
|
+
end
|
61
|
+
else
|
62
|
+
raise ArgumentError, 'Unsupported test runner set, expected :rspec or :minitest'
|
40
63
|
end
|
41
64
|
end
|
42
65
|
end
|
data/spec/.rubocop.yml
ADDED
data/spec/readme_spec.rb
CHANGED
@@ -61,7 +61,7 @@ describe 'A blog post' do
|
|
61
61
|
|
62
62
|
it 'can do all the things a regular model can' do
|
63
63
|
record = BlogPost.new
|
64
|
-
expect(record).
|
64
|
+
expect(record).not_to be_valid
|
65
65
|
record.title = 'foo'
|
66
66
|
expect(record).to be_valid
|
67
67
|
expect(record.save).to eq true
|
@@ -75,8 +75,7 @@ describe 'A blog post' do
|
|
75
75
|
self.abstract_class = true
|
76
76
|
end
|
77
77
|
|
78
|
-
with_model :Ford, superclass: Car
|
79
|
-
end
|
78
|
+
with_model :Ford, superclass: Car
|
80
79
|
|
81
80
|
it 'has a specified superclass' do
|
82
81
|
expect(Ford < Car).to eq true
|
@@ -114,6 +113,6 @@ describe 'with table options' do
|
|
114
113
|
end
|
115
114
|
|
116
115
|
it 'respects the additional options' do
|
117
|
-
expect(WithOptions.columns.map(&:name)).
|
116
|
+
expect(WithOptions.columns.map(&:name)).not_to include('id')
|
118
117
|
end
|
119
118
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# Workaround for JRuby CI failure https://github.com/jruby/jruby/issues/6547#issuecomment-774104996
|
4
|
+
if RUBY_ENGINE == 'jruby'
|
5
|
+
require 'i18n/backend'
|
6
|
+
require 'i18n/backend/simple'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'simplecov'
|
10
|
+
SimpleCov.start
|
5
11
|
|
12
|
+
require 'bundler/setup'
|
6
13
|
require 'with_model'
|
14
|
+
|
7
15
|
RSpec.configure do |config|
|
8
16
|
config.extend WithModel
|
9
17
|
|
@@ -26,9 +34,7 @@ adapter = is_jruby ? 'jdbcsqlite3' : 'sqlite3'
|
|
26
34
|
require 'active_record'
|
27
35
|
ActiveRecord::Base.establish_connection(adapter: adapter, database: ':memory:')
|
28
36
|
|
29
|
-
if defined?(I18n) && I18n.respond_to?(:enforce_available_locales=)
|
30
|
-
I18n.enforce_available_locales = true
|
31
|
-
end
|
37
|
+
I18n.enforce_available_locales = true if defined?(I18n) && I18n.respond_to?(:enforce_available_locales=)
|
32
38
|
|
33
39
|
if ENV['LOGGER']
|
34
40
|
require 'logger'
|
@@ -36,7 +42,7 @@ if ENV['LOGGER']
|
|
36
42
|
end
|
37
43
|
|
38
44
|
module SpecHelper
|
39
|
-
module
|
45
|
+
module RailsTestCompatibility
|
40
46
|
require 'minitest'
|
41
47
|
include Minitest::Assertions
|
42
48
|
|
data/spec/with_model_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
shared_examples_for 'ActiveModel' do
|
7
7
|
require 'active_model/lint'
|
8
|
-
include SpecHelper::
|
8
|
+
include SpecHelper::RailsTestCompatibility
|
9
9
|
include ActiveModel::Lint::Tests
|
10
10
|
|
11
11
|
active_model_methods = ActiveModel::Lint::Tests.public_instance_methods
|
@@ -59,7 +59,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
59
59
|
|
60
60
|
describe 'the class' do
|
61
61
|
subject { BlogPost.new }
|
62
|
-
|
62
|
+
|
63
|
+
it_behaves_like 'ActiveModel'
|
63
64
|
end
|
64
65
|
|
65
66
|
it 'has the methods defined in its model block' do
|
@@ -90,6 +91,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
90
91
|
|
91
92
|
describe 'constant restoration' do
|
92
93
|
before { stub_const('MyConst', 1) }
|
94
|
+
|
93
95
|
shadowing_example_ran = false
|
94
96
|
|
95
97
|
context 'with the with_model block' do
|
@@ -145,6 +147,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
145
147
|
|
146
148
|
describe 'with a name which is namespaced' do
|
147
149
|
before { stub_const('Stuff', Module.new) }
|
150
|
+
|
148
151
|
with_model :'Stuff::BlogPost'
|
149
152
|
|
150
153
|
it 'creates the model in the namespace' do
|
@@ -160,13 +163,16 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
160
163
|
end
|
161
164
|
end
|
162
165
|
|
163
|
-
it 'is available' do
|
166
|
+
it 'is available' do
|
167
|
+
expect(BlogPost).to be
|
168
|
+
end
|
164
169
|
end
|
165
170
|
|
166
171
|
context 'with a mixin' do
|
167
172
|
let(:mixin) do
|
168
173
|
Module.new { def foo; end }
|
169
174
|
end
|
175
|
+
|
170
176
|
before { stub_const('AMixin', mixin) }
|
171
177
|
|
172
178
|
with_model :WithAMixin do
|
@@ -176,12 +182,14 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
176
182
|
end
|
177
183
|
|
178
184
|
it 'has the mixin' do
|
179
|
-
expect(-> { ::WithAMixin.new.foo }).
|
185
|
+
expect(-> { ::WithAMixin.new.foo }).not_to raise_error
|
180
186
|
expect(::WithAMixin.include?(AMixin)).to eq true
|
181
187
|
end
|
182
188
|
end
|
183
189
|
|
184
190
|
context 'with a mixin that has a class_eval' do
|
191
|
+
subject { WithAClassEval.new }
|
192
|
+
|
185
193
|
let(:mixin) do
|
186
194
|
Module.new do
|
187
195
|
def self.included(klass)
|
@@ -191,9 +199,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
191
199
|
end
|
192
200
|
end
|
193
201
|
end
|
194
|
-
before { stub_const('AMixin', mixin) }
|
195
202
|
|
196
|
-
|
203
|
+
before { stub_const('AMixin', mixin) }
|
197
204
|
|
198
205
|
with_model :WithAClassEval do
|
199
206
|
model do
|
@@ -222,7 +229,7 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
222
229
|
end
|
223
230
|
|
224
231
|
it 'respects the additional options' do
|
225
|
-
expect(WithOptions.columns.map(&:name)).
|
232
|
+
expect(WithOptions.columns.map(&:name)).not_to include('id')
|
226
233
|
end
|
227
234
|
end
|
228
235
|
|
@@ -238,12 +245,13 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
238
245
|
|
239
246
|
describe 'the class' do
|
240
247
|
subject { BlogPost.new }
|
241
|
-
|
248
|
+
|
249
|
+
it_behaves_like 'ActiveModel'
|
242
250
|
end
|
243
251
|
end
|
244
252
|
|
245
253
|
context 'with an empty block' do
|
246
|
-
with_model(:BlogPost) {}
|
254
|
+
with_model(:BlogPost) {} # rubocop:disable Lint/EmptyBlock
|
247
255
|
|
248
256
|
it 'acts like a normal ActiveRecord model' do
|
249
257
|
record = BlogPost.create!
|
@@ -254,7 +262,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
254
262
|
|
255
263
|
describe 'the class' do
|
256
264
|
subject { BlogPost.new }
|
257
|
-
|
265
|
+
|
266
|
+
it_behaves_like 'ActiveModel'
|
258
267
|
end
|
259
268
|
end
|
260
269
|
|
@@ -283,7 +292,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
283
292
|
|
284
293
|
describe 'the class' do
|
285
294
|
subject { BlogPost.new }
|
286
|
-
|
295
|
+
|
296
|
+
it_behaves_like 'ActiveModel'
|
287
297
|
end
|
288
298
|
end
|
289
299
|
|
@@ -300,25 +310,32 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
300
310
|
|
301
311
|
describe 'the class' do
|
302
312
|
subject { BlogPost.new }
|
303
|
-
|
313
|
+
|
314
|
+
it_behaves_like 'ActiveModel'
|
304
315
|
end
|
305
316
|
end
|
306
317
|
|
307
318
|
context 'with ActiveSupport::DescendantsTracker' do
|
308
|
-
with_model :BlogPost
|
319
|
+
with_model :BlogPost do
|
320
|
+
model do
|
321
|
+
def self.inspect
|
322
|
+
"BlogPost class #{object_id}"
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
309
326
|
|
310
|
-
|
311
|
-
|
327
|
+
def blog_post_classes
|
328
|
+
ActiveRecord::Base.descendants.select do |c|
|
312
329
|
c.table_name == BlogPost.table_name
|
313
330
|
end
|
314
|
-
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'includes the correct model class in descendants on the first test run' do
|
334
|
+
expect(blog_post_classes).to eq [BlogPost]
|
315
335
|
end
|
316
336
|
|
317
337
|
it 'includes the correct model class in descendants on the second test run' do
|
318
|
-
|
319
|
-
c.table_name == BlogPost.table_name
|
320
|
-
end
|
321
|
-
expect(descendant).to eq BlogPost
|
338
|
+
expect(blog_post_classes).to eq [BlogPost]
|
322
339
|
end
|
323
340
|
end
|
324
341
|
|
@@ -355,7 +372,8 @@ describe 'a temporary ActiveRecord model created with with_model' do
|
|
355
372
|
|
356
373
|
describe 'the class' do
|
357
374
|
subject { BlogPost.new }
|
358
|
-
|
375
|
+
|
376
|
+
it_behaves_like 'ActiveModel'
|
359
377
|
end
|
360
378
|
|
361
379
|
it 'is a subclass of the supplied superclass' do
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
4
|
+
|
5
|
+
# Workaround for JRuby CI failure https://github.com/jruby/jruby/issues/6547#issuecomment-774104996
|
6
|
+
if RUBY_ENGINE == 'jruby'
|
7
|
+
require 'i18n/backend'
|
8
|
+
require 'i18n/backend/simple'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'with_model'
|
12
|
+
require 'minitest/autorun'
|
13
|
+
|
14
|
+
WithModel.runner = :minitest
|
15
|
+
|
16
|
+
module MiniTest
|
17
|
+
class Test
|
18
|
+
extend WithModel
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
is_jruby = RUBY_PLATFORM == 'java'
|
23
|
+
adapter = is_jruby ? 'jdbcsqlite3' : 'sqlite3'
|
24
|
+
|
25
|
+
# WithModel requires ActiveRecord::Base.connection to be established.
|
26
|
+
# If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
|
27
|
+
require 'active_record'
|
28
|
+
ActiveRecord::Base.establish_connection(adapter: adapter, database: ':memory:')
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class WithModelTest < MiniTest::Test
|
6
|
+
with_model :BlogPost do
|
7
|
+
table do |t|
|
8
|
+
t.string 'title'
|
9
|
+
t.text 'content'
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
model do
|
14
|
+
def fancy_title
|
15
|
+
"Title: #{title}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_it_should_act_like_a_normal_active_record_model # rubocop:disable Minitest/MultipleAssertions
|
21
|
+
record = BlogPost.create!(title: 'New blog post', content: 'Hello, world!')
|
22
|
+
|
23
|
+
record.reload
|
24
|
+
|
25
|
+
assert_equal 'New blog post', record.title
|
26
|
+
assert_equal 'Hello, world!', record.content
|
27
|
+
assert record.updated_at
|
28
|
+
|
29
|
+
record.destroy
|
30
|
+
|
31
|
+
assert_raises ActiveRecord::RecordNotFound do
|
32
|
+
record.reload
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_it_has_the_methods_defined_in_its_model_block
|
37
|
+
assert_equal 'Title: New blog post', BlogPost.new(title: 'New blog post').fancy_title
|
38
|
+
end
|
39
|
+
end
|
data/with_model.gemspec
CHANGED
@@ -12,20 +12,28 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = 'Dynamically build a model within an RSpec context'
|
13
13
|
spec.description = spec.summary
|
14
14
|
spec.license = 'MIT'
|
15
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
15
16
|
|
16
17
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
|
-
spec.executables = spec.files.grep(%r
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ['lib']
|
20
21
|
|
21
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.6'
|
22
23
|
|
23
|
-
spec.add_dependency 'activerecord', '>=
|
24
|
+
spec.add_dependency 'activerecord', '>= 5.2'
|
24
25
|
|
25
|
-
spec.add_development_dependency 'bundler'
|
26
|
+
spec.add_development_dependency 'bundler'
|
26
27
|
spec.add_development_dependency 'minitest'
|
28
|
+
spec.add_development_dependency 'pry'
|
27
29
|
spec.add_development_dependency 'rake'
|
28
|
-
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
32
|
+
spec.add_development_dependency 'rubocop-minitest'
|
33
|
+
spec.add_development_dependency 'rubocop-rake'
|
34
|
+
spec.add_development_dependency 'rubocop-rspec'
|
35
|
+
spec.add_development_dependency 'simplecov'
|
36
|
+
spec.add_development_dependency 'yard'
|
29
37
|
|
30
38
|
if RUBY_PLATFORM == 'java'
|
31
39
|
spec.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: with_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Case Commons, LLC
|
8
8
|
- Grant Hutchins
|
9
9
|
- Andrew Marshall
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,34 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
22
|
-
- - "<"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '6.0'
|
21
|
+
version: '5.2'
|
25
22
|
type: :runtime
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
requirements:
|
29
26
|
- - ">="
|
30
27
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
32
|
-
- - "<"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '6.0'
|
28
|
+
version: '5.2'
|
35
29
|
- !ruby/object:Gem::Dependency
|
36
30
|
name: bundler
|
37
31
|
requirement: !ruby/object:Gem::Requirement
|
38
32
|
requirements:
|
39
|
-
- - "
|
33
|
+
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
35
|
+
version: '0'
|
42
36
|
type: :development
|
43
37
|
prerelease: false
|
44
38
|
version_requirements: !ruby/object:Gem::Requirement
|
45
39
|
requirements:
|
46
|
-
- - "
|
40
|
+
- - ">="
|
47
41
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
42
|
+
version: '0'
|
49
43
|
- !ruby/object:Gem::Dependency
|
50
44
|
name: minitest
|
51
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +54,20 @@ dependencies:
|
|
60
54
|
- - ">="
|
61
55
|
- !ruby/object:Gem::Version
|
62
56
|
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: pry
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
63
71
|
- !ruby/object:Gem::Dependency
|
64
72
|
name: rake
|
65
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,16 +86,100 @@ dependencies:
|
|
78
86
|
name: rspec
|
79
87
|
requirement: !ruby/object:Gem::Requirement
|
80
88
|
requirements:
|
81
|
-
- - "
|
89
|
+
- - ">="
|
82
90
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
91
|
+
version: '0'
|
84
92
|
type: :development
|
85
93
|
prerelease: false
|
86
94
|
version_requirements: !ruby/object:Gem::Requirement
|
87
95
|
requirements:
|
88
|
-
- - "
|
96
|
+
- - ">="
|
89
97
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rubocop
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rubocop-minitest
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: rubocop-rake
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: rubocop-rspec
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: simplecov
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: yard
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
91
183
|
- !ruby/object:Gem::Dependency
|
92
184
|
name: sqlite3
|
93
185
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,10 +203,12 @@ executables: []
|
|
111
203
|
extensions: []
|
112
204
|
extra_rdoc_files: []
|
113
205
|
files:
|
206
|
+
- ".github/workflows/ci.yml"
|
114
207
|
- ".gitignore"
|
208
|
+
- ".jrubyrc"
|
115
209
|
- ".rspec"
|
116
210
|
- ".rubocop.yml"
|
117
|
-
- ".
|
211
|
+
- ".rubocop_todo.yml"
|
118
212
|
- ".yardopts"
|
119
213
|
- CHANGELOG.md
|
120
214
|
- Gemfile
|
@@ -128,17 +222,21 @@ files:
|
|
128
222
|
- lib/with_model/model/dsl.rb
|
129
223
|
- lib/with_model/table.rb
|
130
224
|
- lib/with_model/version.rb
|
225
|
+
- spec/.rubocop.yml
|
131
226
|
- spec/active_record_behaviors_spec.rb
|
132
227
|
- spec/constant_stubber_spec.rb
|
133
228
|
- spec/readme_spec.rb
|
134
229
|
- spec/spec_helper.rb
|
135
230
|
- spec/with_model_spec.rb
|
231
|
+
- test/test_helper.rb
|
232
|
+
- test/with_model_test.rb
|
136
233
|
- with_model.gemspec
|
137
234
|
homepage: https://github.com/Casecommons/with_model
|
138
235
|
licenses:
|
139
236
|
- MIT
|
140
|
-
metadata:
|
141
|
-
|
237
|
+
metadata:
|
238
|
+
rubygems_mfa_required: 'true'
|
239
|
+
post_install_message:
|
142
240
|
rdoc_options: []
|
143
241
|
require_paths:
|
144
242
|
- lib
|
@@ -146,21 +244,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
244
|
requirements:
|
147
245
|
- - ">="
|
148
246
|
- !ruby/object:Gem::Version
|
149
|
-
version: '2.
|
247
|
+
version: '2.6'
|
150
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
249
|
requirements:
|
152
250
|
- - ">="
|
153
251
|
- !ruby/object:Gem::Version
|
154
252
|
version: '0'
|
155
253
|
requirements: []
|
156
|
-
|
157
|
-
|
158
|
-
signing_key:
|
254
|
+
rubygems_version: 3.3.3
|
255
|
+
signing_key:
|
159
256
|
specification_version: 4
|
160
257
|
summary: Dynamically build a model within an RSpec context
|
161
258
|
test_files:
|
259
|
+
- spec/.rubocop.yml
|
162
260
|
- spec/active_record_behaviors_spec.rb
|
163
261
|
- spec/constant_stubber_spec.rb
|
164
262
|
- spec/readme_spec.rb
|
165
263
|
- spec/spec_helper.rb
|
166
264
|
- spec/with_model_spec.rb
|
265
|
+
- test/test_helper.rb
|
266
|
+
- test/with_model_test.rb
|
data/.travis.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
rvm:
|
5
|
-
- "2.5.1"
|
6
|
-
- "2.4.4"
|
7
|
-
- "2.3.7"
|
8
|
-
- jruby-9.2.0.0
|
9
|
-
|
10
|
-
install:
|
11
|
-
- bundle install --retry=3
|
12
|
-
|
13
|
-
env:
|
14
|
-
- ACTIVE_RECORD_BRANCH="master"
|
15
|
-
- ACTIVE_RECORD_BRANCH="5-2-stable"
|
16
|
-
- ACTIVE_RECORD_VERSION="~> 5.2.0"
|
17
|
-
- ACTIVE_RECORD_VERSION="~> 5.1.0"
|
18
|
-
- ACTIVE_RECORD_VERSION="~> 5.0.0"
|
19
|
-
- ACTIVE_RECORD_VERSION="~> 4.2.0"
|
20
|
-
|
21
|
-
matrix:
|
22
|
-
allow_failures:
|
23
|
-
- env: ACTIVE_RECORD_BRANCH="master"
|
24
|
-
- env: ACTIVE_RECORD_BRANCH="5-2-stable"
|
25
|
-
exclude:
|
26
|
-
- rvm: 2.3.7
|
27
|
-
env: ACTIVE_RECORD_BRANCH="master"
|
28
|
-
- rvm: jruby-9.2.0.0
|
29
|
-
env: ACTIVE_RECORD_BRANCH="master"
|
30
|
-
- rvm: jruby-9.2.0.0
|
31
|
-
env: ACTIVE_RECORD_BRANCH="5-2-stable"
|
32
|
-
- rvm: jruby-9.2.0.0
|
33
|
-
env: ACTIVE_RECORD_VERSION="~> 5.2.0"
|
34
|
-
- rvm: jruby-9.2.0.0
|
35
|
-
env: ACTIVE_RECORD_VERSION="~> 4.2.0"
|
36
|
-
|
37
|
-
addons:
|
38
|
-
code_climate:
|
39
|
-
repo_token: fe5c8a8b1b951a54707c08b6fb2a9a5edf9e0522d28bccc648454f774c9ccab1
|