with_model 2.1.7 → 2.2.0
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 +20 -9
- data/.rspec +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +21 -23
- data/Rakefile +8 -17
- data/lib/with_model/constant_stubber.rb +1 -1
- data/lib/with_model/descendants_tracker.rb +87 -0
- data/lib/with_model/model.rb +12 -16
- data/lib/with_model/table.rb +6 -6
- data/lib/with_model/version.rb +1 -1
- data/lib/with_model.rb +6 -6
- data/spec/active_record_behaviors_spec.rb +27 -27
- data/spec/constant_stubber_spec.rb +5 -5
- data/spec/descendants_tracking_spec.rb +48 -0
- data/spec/readme_spec.rb +24 -24
- data/spec/spec_helper.rb +7 -19
- data/spec/with_model_spec.rb +109 -118
- data/test/test_helper.rb +7 -18
- data/test/with_model_test.rb +9 -9
- data/with_model.gemspec +15 -15
- metadata +8 -12
- data/.rubocop.yml +0 -33
- data/.rubocop_todo.yml +0 -78
- data/spec/.rubocop.yml +0 -5
data/test/test_helper.rb
CHANGED
@@ -1,28 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
require 'i18n/backend'
|
8
|
-
require 'i18n/backend/simple'
|
9
|
-
end
|
10
|
-
|
11
|
-
require 'with_model'
|
12
|
-
require 'minitest/autorun'
|
5
|
+
require "with_model"
|
6
|
+
require "minitest/autorun"
|
13
7
|
|
14
8
|
WithModel.runner = :minitest
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
extend WithModel
|
19
|
-
end
|
10
|
+
Minitest::Test.class_eval do
|
11
|
+
extend WithModel
|
20
12
|
end
|
21
13
|
|
22
|
-
is_jruby = RUBY_PLATFORM == 'java'
|
23
|
-
adapter = is_jruby ? 'jdbcsqlite3' : 'sqlite3'
|
24
|
-
|
25
14
|
# WithModel requires ActiveRecord::Base.connection to be established.
|
26
15
|
# If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
|
27
|
-
require
|
28
|
-
ActiveRecord::Base.establish_connection(adapter:
|
16
|
+
require "active_record"
|
17
|
+
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
data/test/with_model_test.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
|
-
class WithModelTest <
|
5
|
+
class WithModelTest < Minitest::Test
|
6
6
|
with_model :BlogPost do
|
7
7
|
table do |t|
|
8
|
-
t.string
|
9
|
-
t.text
|
8
|
+
t.string "title"
|
9
|
+
t.text "content"
|
10
10
|
t.timestamps null: false
|
11
11
|
end
|
12
12
|
|
@@ -17,13 +17,13 @@ class WithModelTest < MiniTest::Test
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def test_it_should_act_like_a_normal_active_record_model
|
21
|
-
record = BlogPost.create!(title:
|
20
|
+
def test_it_should_act_like_a_normal_active_record_model
|
21
|
+
record = BlogPost.create!(title: "New blog post", content: "Hello, world!")
|
22
22
|
|
23
23
|
record.reload
|
24
24
|
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
25
|
+
assert_equal "New blog post", record.title
|
26
|
+
assert_equal "Hello, world!", record.content
|
27
27
|
assert record.updated_at
|
28
28
|
|
29
29
|
record.destroy
|
@@ -34,6 +34,6 @@ class WithModelTest < MiniTest::Test
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_it_has_the_methods_defined_in_its_model_block
|
37
|
-
assert_equal
|
37
|
+
assert_equal "Title: New blog post", BlogPost.new(title: "New blog post").fancy_title
|
38
38
|
end
|
39
39
|
end
|
data/with_model.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.push File.expand_path(
|
4
|
-
require
|
3
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
4
|
+
require "with_model/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.homepage
|
12
|
-
spec.summary
|
7
|
+
spec.name = "with_model"
|
8
|
+
spec.version = WithModel::VERSION
|
9
|
+
spec.authors = ["Case Commons, LLC", "Grant Hutchins", "Andrew Marshall"]
|
10
|
+
spec.email = %w[casecommons-dev@googlegroups.com gems@nertzy.com andrew@johnandrewmarshall.com]
|
11
|
+
spec.homepage = "https://github.com/Casecommons/with_model"
|
12
|
+
spec.summary = "Dynamically build a model within an RSpec context"
|
13
13
|
spec.description = spec.summary
|
14
|
-
spec.license
|
15
|
-
spec.metadata[
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
spec.executables
|
19
|
-
spec.require_paths = [
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version =
|
21
|
+
spec.required_ruby_version = ">= 3.1"
|
22
22
|
|
23
|
-
spec.add_dependency
|
23
|
+
spec.add_dependency "activerecord", ">= 7.0"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: with_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Case Commons, LLC
|
8
8
|
- Grant Hutchins
|
9
9
|
- Andrew Marshall
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2025-02-04 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activerecord
|
@@ -18,14 +17,14 @@ dependencies:
|
|
18
17
|
requirements:
|
19
18
|
- - ">="
|
20
19
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
20
|
+
version: '7.0'
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
24
|
requirements:
|
26
25
|
- - ">="
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
27
|
+
version: '7.0'
|
29
28
|
description: Dynamically build a model within an RSpec context
|
30
29
|
email:
|
31
30
|
- casecommons-dev@googlegroups.com
|
@@ -41,8 +40,6 @@ files:
|
|
41
40
|
- ".gitignore"
|
42
41
|
- ".jrubyrc"
|
43
42
|
- ".rspec"
|
44
|
-
- ".rubocop.yml"
|
45
|
-
- ".rubocop_todo.yml"
|
46
43
|
- ".yardopts"
|
47
44
|
- CHANGELOG.md
|
48
45
|
- Gemfile
|
@@ -51,14 +48,15 @@ files:
|
|
51
48
|
- Rakefile
|
52
49
|
- lib/with_model.rb
|
53
50
|
- lib/with_model/constant_stubber.rb
|
51
|
+
- lib/with_model/descendants_tracker.rb
|
54
52
|
- lib/with_model/methods.rb
|
55
53
|
- lib/with_model/model.rb
|
56
54
|
- lib/with_model/model/dsl.rb
|
57
55
|
- lib/with_model/table.rb
|
58
56
|
- lib/with_model/version.rb
|
59
|
-
- spec/.rubocop.yml
|
60
57
|
- spec/active_record_behaviors_spec.rb
|
61
58
|
- spec/constant_stubber_spec.rb
|
59
|
+
- spec/descendants_tracking_spec.rb
|
62
60
|
- spec/readme_spec.rb
|
63
61
|
- spec/spec_helper.rb
|
64
62
|
- spec/with_model_spec.rb
|
@@ -70,7 +68,6 @@ licenses:
|
|
70
68
|
- MIT
|
71
69
|
metadata:
|
72
70
|
rubygems_mfa_required: 'true'
|
73
|
-
post_install_message:
|
74
71
|
rdoc_options: []
|
75
72
|
require_paths:
|
76
73
|
- lib
|
@@ -78,15 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
75
|
requirements:
|
79
76
|
- - ">="
|
80
77
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
78
|
+
version: '3.1'
|
82
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
80
|
requirements:
|
84
81
|
- - ">="
|
85
82
|
- !ruby/object:Gem::Version
|
86
83
|
version: '0'
|
87
84
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
89
|
-
signing_key:
|
85
|
+
rubygems_version: 3.6.3
|
90
86
|
specification_version: 4
|
91
87
|
summary: Dynamically build a model within an RSpec context
|
92
88
|
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
|
-
require:
|
4
|
-
- rubocop-rake
|
5
|
-
- rubocop-rspec
|
6
|
-
- rubocop-minitest
|
7
|
-
|
8
|
-
AllCops:
|
9
|
-
NewCops: enable
|
10
|
-
TargetRubyVersion: 2.7
|
11
|
-
Exclude:
|
12
|
-
- 'bin/**/*'
|
13
|
-
- 'vendor/bundle/**/*'
|
14
|
-
|
15
|
-
Metrics/BlockLength:
|
16
|
-
Exclude:
|
17
|
-
- 'spec/**/*'
|
18
|
-
- 'with_model.gemspec'
|
19
|
-
|
20
|
-
Bundler/OrderedGems:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Bundler/DuplicatedGem:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
RSpec/Be:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
RSpec/BeforeAfterAll:
|
30
|
-
Enabled: false
|
31
|
-
|
32
|
-
Style/Documentation:
|
33
|
-
Enabled: false
|
data/.rubocop_todo.yml
DELETED
@@ -1,78 +0,0 @@
|
|
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'
|