unidom-common-rspec 1.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -24
- data/Gemfile.lock +73 -67
- data/README.md +6 -3
- data/ROADMAP.md +43 -24
- data/lib/unidom/common/rspec.rb +3 -1
- data/lib/unidom/common/rspec/each_validator_shared_examples.rb +10 -4
- data/lib/unidom/common/rspec/scope_shared_examples.rb +24 -2
- data/lib/unidom/common/rspec/validates_numericality_shared_examples.rb +2 -2
- data/lib/unidom/common/rspec/version.rb +1 -1
- data/unidom-common-rspec.gemspec +3 -3
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4dc4838103d8f1759f6c4b00f74555c6de686ac3c74435e3b6ac61bcbe9d8f2
|
4
|
+
data.tar.gz: a2fa3ca52eeb5c6129eb518f4f6fc21eec9283ab991cd91b4cbe4c77f1458844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2276222c6654378ee738bd82d8b729565baca2477ff9bb2dbf1c3985e29420421cd0f4e7394742e45dd4f934b8913eee4899af559b411329b68396938214449c
|
7
|
+
data.tar.gz: c170cd5e5513c60a8dfdb3fa140e2e1b0096c8d3ab09f5e2b52406111a163524340b7e8380a4281f22b4291b93d6fe33e22f93389fb1890b75f679a50524196c
|
data/CHANGELOG.md
CHANGED
@@ -2,75 +2,94 @@
|
|
2
2
|
|
3
3
|
## v0.1
|
4
4
|
|
5
|
-
1. Scope shared examples
|
5
|
+
1. Scope shared examples.
|
6
6
|
|
7
7
|
## v0.2
|
8
8
|
|
9
|
-
1. Validates shared examples
|
9
|
+
1. Validates shared examples.
|
10
10
|
|
11
11
|
## v0.3
|
12
12
|
|
13
|
-
1. Model Extension shared examples
|
13
|
+
1. Model Extension shared examples.
|
14
14
|
|
15
15
|
## v0.4
|
16
16
|
|
17
|
-
1. Has Many shared examples
|
17
|
+
1. Has Many shared examples.
|
18
18
|
|
19
19
|
## v0.5
|
20
20
|
|
21
|
-
1. Belongs To shared examples
|
22
|
-
2. Improved the Model Extension shared examples for the validates behaviors of the #``grade`` attribute & the #``priority`` attribute
|
23
|
-
3. Improved the Model Extension shared examples for the scope behaviours of the #``priority`` attribute
|
21
|
+
1. Belongs To shared examples.
|
22
|
+
2. Improved the Model Extension shared examples for the validates behaviors of the #``grade`` attribute & the #``priority`` attribute.
|
23
|
+
3. Improved the Model Extension shared examples for the scope behaviours of the #``priority`` attribute.
|
24
24
|
|
25
25
|
## v0.6
|
26
26
|
|
27
|
-
1. Has One shared examples
|
27
|
+
1. Has One shared examples.
|
28
28
|
|
29
29
|
## v0.6.1
|
30
30
|
|
31
|
-
1. Improved the Belongs To shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method
|
32
|
-
2. Improved the Has One shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method
|
31
|
+
1. Improved the Belongs To shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method.
|
32
|
+
2. Improved the Has One shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method.
|
33
33
|
|
34
34
|
## v0.6.2
|
35
35
|
|
36
|
-
1. Improved the Has Many shared examples for the #``collection.build`` method, the #``collection.create`` method, & the #``collection.create!`` method
|
36
|
+
1. Improved the Has Many shared examples for the #``collection.build`` method, the #``collection.create`` method, & the #``collection.create!`` method.
|
37
37
|
|
38
38
|
## v0.7
|
39
39
|
|
40
|
-
1. Each Validator shared examples
|
40
|
+
1. Each Validator shared examples.
|
41
41
|
|
42
42
|
## v0.7.1
|
43
43
|
|
44
|
-
1. Improved the Model Extension shared examples for the ``ordinal_is`` scope, the ``grade_is`` scope, the ``grade_higher_than`` scope, the ``grade_lower_than`` scope, the ``priority_is`` scope, the ``priority_higher_than`` scope, & the ``priority_lower_than`` scope
|
45
|
-
2. Improved the Model Extension shared examples for the validations on the #``ordinal`` attribute
|
44
|
+
1. Improved the Model Extension shared examples for the ``ordinal_is`` scope, the ``grade_is`` scope, the ``grade_higher_than`` scope, the ``grade_lower_than`` scope, the ``priority_is`` scope, the ``priority_higher_than`` scope, & the ``priority_lower_than`` scope.
|
45
|
+
2. Improved the Model Extension shared examples for the validations on the #``ordinal`` attribute.
|
46
46
|
|
47
47
|
## v0.7.2
|
48
48
|
|
49
|
-
1. Improved the Validates shared examples for the failure message
|
49
|
+
1. Improved the Validates shared examples for the failure message.
|
50
50
|
|
51
51
|
## v0.8
|
52
52
|
|
53
|
-
1. Monomorphic Scope shared examples
|
54
|
-
2. Polymorphic Scope shared examples
|
53
|
+
1. Monomorphic Scope shared examples.
|
54
|
+
2. Polymorphic Scope shared examples.
|
55
55
|
|
56
56
|
## v0.9
|
57
57
|
|
58
|
-
1. Validates Text shared examples
|
59
|
-
2. Validates Numericality shared examples
|
58
|
+
1. Validates Text shared examples.
|
59
|
+
2. Validates Numericality shared examples.
|
60
60
|
|
61
61
|
## v0.9.1
|
62
62
|
|
63
|
-
1. Improved the Validates Text shared examples for the length
|
63
|
+
1. Improved the Validates Text shared examples for the length.
|
64
64
|
|
65
65
|
## v0.10
|
66
66
|
|
67
|
-
1. Assert Present shared examples
|
67
|
+
1. Assert Present shared examples.
|
68
68
|
|
69
69
|
## v0.10.1
|
70
70
|
|
71
|
-
1.
|
72
|
-
2.
|
71
|
+
1. Improved the Scope shared examples to separate the Monomorphic Scope shared examples, & the Polymorphic Scope shared examples.
|
72
|
+
2. Improved the Validates shared examples to separate the Validates Text shared examples, & the Validates Numericality shared examples.
|
73
73
|
|
74
74
|
## v1.0
|
75
75
|
|
76
|
-
1.
|
76
|
+
1. Improved the compatibility for Rails 6.x & RSpec Rails 4.x.
|
77
|
+
|
78
|
+
## v1.1
|
79
|
+
|
80
|
+
1. Improved the Ruby Gem Specification to depend on Rake v13.0 & RSpec v3.9.
|
81
|
+
|
82
|
+
## v2.0
|
83
|
+
|
84
|
+
1. Improved the Scope shared examples for Ruby 3.0.
|
85
|
+
|
86
|
+
## v2.0.1
|
87
|
+
|
88
|
+
1. Improved the compatibility of Validates Numericality shared examples and Each Validator shared examples.
|
89
|
+
|
90
|
+
## v2.0.2
|
91
|
+
|
92
|
+
1. Improved the Ruby Gem Specification for homepage URL.
|
93
|
+
2. Improved the Ruby Gem Specification to depend on RSpec Rails 5.x.
|
94
|
+
3. Upgraded the Gemfile.lock file.
|
95
|
+
4. Cleaned the un-used RSpec examples.
|
data/Gemfile.lock
CHANGED
@@ -1,91 +1,97 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
unidom-common-rspec (0.
|
4
|
+
unidom-common-rspec (2.0.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionpack (
|
10
|
-
actionview (=
|
11
|
-
activesupport (=
|
12
|
-
rack (~> 2.0)
|
13
|
-
rack-test (
|
9
|
+
actionpack (6.1.4)
|
10
|
+
actionview (= 6.1.4)
|
11
|
+
activesupport (= 6.1.4)
|
12
|
+
rack (~> 2.0, >= 2.0.9)
|
13
|
+
rack-test (>= 0.6.3)
|
14
14
|
rails-dom-testing (~> 2.0)
|
15
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
16
|
-
actionview (
|
17
|
-
activesupport (=
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
16
|
+
actionview (6.1.4)
|
17
|
+
activesupport (= 6.1.4)
|
18
18
|
builder (~> 3.1)
|
19
|
-
|
19
|
+
erubi (~> 1.4)
|
20
20
|
rails-dom-testing (~> 2.0)
|
21
|
-
rails-html-sanitizer (~> 1.
|
22
|
-
activesupport (
|
21
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
22
|
+
activesupport (6.1.4)
|
23
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
-
i18n (
|
25
|
-
minitest (
|
26
|
-
tzinfo (~>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
tzinfo (~> 2.0)
|
27
|
+
zeitwerk (~> 2.3)
|
28
|
+
builder (3.2.4)
|
29
|
+
concurrent-ruby (1.1.9)
|
30
|
+
crass (1.0.6)
|
31
|
+
diff-lcs (1.4.4)
|
32
|
+
erubi (1.10.0)
|
33
|
+
i18n (1.8.10)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
loofah (2.11.0)
|
36
|
+
crass (~> 1.0.2)
|
33
37
|
nokogiri (>= 1.5.9)
|
34
|
-
method_source (0.
|
35
|
-
mini_portile2 (2.1
|
36
|
-
minitest (5.
|
37
|
-
nokogiri (1.
|
38
|
-
mini_portile2 (~> 2.1
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
method_source (1.0.0)
|
39
|
+
mini_portile2 (2.6.1)
|
40
|
+
minitest (5.14.4)
|
41
|
+
nokogiri (1.12.0)
|
42
|
+
mini_portile2 (~> 2.6.1)
|
43
|
+
racc (~> 1.4)
|
44
|
+
racc (1.5.2)
|
45
|
+
rack (2.2.3)
|
46
|
+
rack-test (1.1.0)
|
47
|
+
rack (>= 1.0, < 3)
|
48
|
+
rails-dom-testing (2.0.3)
|
49
|
+
activesupport (>= 4.2.0)
|
50
|
+
nokogiri (>= 1.6)
|
51
|
+
rails-html-sanitizer (1.3.0)
|
52
|
+
loofah (~> 2.3)
|
53
|
+
railties (6.1.4)
|
54
|
+
actionpack (= 6.1.4)
|
55
|
+
activesupport (= 6.1.4)
|
50
56
|
method_source
|
51
|
-
rake (>= 0.
|
52
|
-
thor (
|
53
|
-
rake (
|
54
|
-
rspec (3.
|
55
|
-
rspec-core (~> 3.
|
56
|
-
rspec-expectations (~> 3.
|
57
|
-
rspec-mocks (~> 3.
|
58
|
-
rspec-core (3.
|
59
|
-
rspec-support (~> 3.
|
60
|
-
rspec-expectations (3.
|
57
|
+
rake (>= 0.13)
|
58
|
+
thor (~> 1.0)
|
59
|
+
rake (13.0.6)
|
60
|
+
rspec (3.10.0)
|
61
|
+
rspec-core (~> 3.10.0)
|
62
|
+
rspec-expectations (~> 3.10.0)
|
63
|
+
rspec-mocks (~> 3.10.0)
|
64
|
+
rspec-core (3.10.1)
|
65
|
+
rspec-support (~> 3.10.0)
|
66
|
+
rspec-expectations (3.10.1)
|
61
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
-
rspec-support (~> 3.
|
63
|
-
rspec-mocks (3.
|
68
|
+
rspec-support (~> 3.10.0)
|
69
|
+
rspec-mocks (3.10.2)
|
64
70
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-rails (
|
67
|
-
actionpack (>=
|
68
|
-
activesupport (>=
|
69
|
-
railties (>=
|
70
|
-
rspec-core (~> 3.
|
71
|
-
rspec-expectations (~> 3.
|
72
|
-
rspec-mocks (~> 3.
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-support (3.
|
75
|
-
thor (
|
76
|
-
|
77
|
-
|
78
|
-
|
71
|
+
rspec-support (~> 3.10.0)
|
72
|
+
rspec-rails (5.0.1)
|
73
|
+
actionpack (>= 5.2)
|
74
|
+
activesupport (>= 5.2)
|
75
|
+
railties (>= 5.2)
|
76
|
+
rspec-core (~> 3.10)
|
77
|
+
rspec-expectations (~> 3.10)
|
78
|
+
rspec-mocks (~> 3.10)
|
79
|
+
rspec-support (~> 3.10)
|
80
|
+
rspec-support (3.10.2)
|
81
|
+
thor (1.1.0)
|
82
|
+
tzinfo (2.0.4)
|
83
|
+
concurrent-ruby (~> 1.0)
|
84
|
+
zeitwerk (2.4.2)
|
79
85
|
|
80
86
|
PLATFORMS
|
81
87
|
ruby
|
82
88
|
|
83
89
|
DEPENDENCIES
|
84
|
-
bundler (~>
|
85
|
-
rake (~>
|
90
|
+
bundler (~> 2.0)
|
91
|
+
rake (~> 13.0)
|
86
92
|
rspec (~> 3.0)
|
87
|
-
rspec-rails (~>
|
93
|
+
rspec-rails (~> 5.0)
|
88
94
|
unidom-common-rspec!
|
89
95
|
|
90
96
|
BUNDLED WITH
|
91
|
-
|
97
|
+
2.2.13
|
data/README.md
CHANGED
@@ -27,12 +27,15 @@ gem 'unidom-common-rspec'
|
|
27
27
|
|
28
28
|
And then execute:
|
29
29
|
|
30
|
-
|
30
|
+
```shell
|
31
|
+
$ bundle
|
32
|
+
```
|
31
33
|
|
32
34
|
Or install it yourself as:
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
```shell
|
37
|
+
$ gem install unidom-common-rspec
|
38
|
+
```
|
36
39
|
|
37
40
|
|
38
41
|
## Usage
|
data/ROADMAP.md
CHANGED
@@ -2,75 +2,94 @@
|
|
2
2
|
|
3
3
|
## v0.1
|
4
4
|
|
5
|
-
1. Scope shared examples
|
5
|
+
1. Scope shared examples.
|
6
6
|
|
7
7
|
## v0.2
|
8
8
|
|
9
|
-
1. Validates shared examples
|
9
|
+
1. Validates shared examples.
|
10
10
|
|
11
11
|
## v0.3
|
12
12
|
|
13
|
-
1. Model Extension shared examples
|
13
|
+
1. Model Extension shared examples.
|
14
14
|
|
15
15
|
## v0.4
|
16
16
|
|
17
|
-
1. Has Many shared examples
|
17
|
+
1. Has Many shared examples.
|
18
18
|
|
19
19
|
## v0.5
|
20
20
|
|
21
|
-
1. Belongs To shared examples
|
22
|
-
2. Improve the Model Extension shared examples for the validates behaviors of the #``grade`` attribute & the #``priority`` attribute
|
23
|
-
3. Improve the Model Extension shared examples for the scope behaviours of the #``priority`` attribute
|
21
|
+
1. Belongs To shared examples.
|
22
|
+
2. Improve the Model Extension shared examples for the validates behaviors of the #``grade`` attribute & the #``priority`` attribute.
|
23
|
+
3. Improve the Model Extension shared examples for the scope behaviours of the #``priority`` attribute.
|
24
24
|
|
25
25
|
## v0.6
|
26
26
|
|
27
|
-
1. Has One shared examples
|
27
|
+
1. Has One shared examples.
|
28
28
|
|
29
29
|
## v0.6.1
|
30
30
|
|
31
|
-
1. Improve the Belongs To shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method
|
32
|
-
2. Improve the Has One shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method
|
31
|
+
1. Improve the Belongs To shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method.
|
32
|
+
2. Improve the Has One shared examples for the #``build_association`` method, the #``create_association`` method, & the #``create_association!`` method.
|
33
33
|
|
34
34
|
## v0.6.2
|
35
35
|
|
36
|
-
1. Improve the Has Many shared examples for the #``collection.build`` method, the #``collection.create`` method, & the #``collection.create!`` method
|
36
|
+
1. Improve the Has Many shared examples for the #``collection.build`` method, the #``collection.create`` method, & the #``collection.create!`` method.
|
37
37
|
|
38
38
|
## v0.7
|
39
39
|
|
40
|
-
1. Each Validator shared examples
|
40
|
+
1. Each Validator shared examples.
|
41
41
|
|
42
42
|
## v0.7.1
|
43
43
|
|
44
|
-
1. Improve the Model Extension shared examples for the ``ordinal_is`` scope, the ``grade_is`` scope, the ``grade_higher_than`` scope, the ``grade_lower_than`` scope, the ``priority_is`` scope, the ``priority_higher_than`` scope, & the ``priority_lower_than`` scope
|
45
|
-
2. Improve the Model Extension shared examples for the validations on the #``ordinal`` attribute
|
44
|
+
1. Improve the Model Extension shared examples for the ``ordinal_is`` scope, the ``grade_is`` scope, the ``grade_higher_than`` scope, the ``grade_lower_than`` scope, the ``priority_is`` scope, the ``priority_higher_than`` scope, & the ``priority_lower_than`` scope.
|
45
|
+
2. Improve the Model Extension shared examples for the validations on the #``ordinal`` attribute.
|
46
46
|
|
47
47
|
## v0.7.2
|
48
48
|
|
49
|
-
1. Improve the Validates shared examples for the failure message
|
49
|
+
1. Improve the Validates shared examples for the failure message.
|
50
50
|
|
51
51
|
## v0.8
|
52
52
|
|
53
|
-
1. Monomorphic Scope shared examples
|
54
|
-
2. Polymorphic Scope shared examples
|
53
|
+
1. Monomorphic Scope shared examples.
|
54
|
+
2. Polymorphic Scope shared examples.
|
55
55
|
|
56
56
|
## v0.9
|
57
57
|
|
58
|
-
1. Validates Text shared examples
|
59
|
-
2. Validates Numericality shared examples
|
58
|
+
1. Validates Text shared examples.
|
59
|
+
2. Validates Numericality shared examples.
|
60
60
|
|
61
61
|
## v0.9.1
|
62
62
|
|
63
|
-
1. Improve the Validates Text shared examples for the length
|
63
|
+
1. Improve the Validates Text shared examples for the length.
|
64
64
|
|
65
65
|
## v0.10
|
66
66
|
|
67
|
-
1. Assert Present shared examples
|
67
|
+
1. Assert Present shared examples.
|
68
68
|
|
69
69
|
## v0.10.1
|
70
70
|
|
71
|
-
1. Improve the Scope shared examples to separate the Monomorphic Scope shared examples, & the Polymorphic Scope shared examples
|
72
|
-
2. Improve the Validates shared examples to separate the Validates Text shared examples, & the Validates Numericality shared examples
|
71
|
+
1. Improve the Scope shared examples to separate the Monomorphic Scope shared examples, & the Polymorphic Scope shared examples.
|
72
|
+
2. Improve the Validates shared examples to separate the Validates Text shared examples, & the Validates Numericality shared examples.
|
73
73
|
|
74
74
|
## v1.0
|
75
75
|
|
76
|
-
1. Improve the compatibility for Rails 6.x & RSpec Rails 4.x
|
76
|
+
1. Improve the compatibility for Rails 6.x & RSpec Rails 4.x.
|
77
|
+
|
78
|
+
## v1.1
|
79
|
+
|
80
|
+
1. Improve the Ruby Gem Specification to depend on Rake v13.0, & RSpec v4.0.
|
81
|
+
|
82
|
+
## v2.0
|
83
|
+
|
84
|
+
1. Improve the Scope shared examples for Ruby 3.0.
|
85
|
+
|
86
|
+
## v2.0.1
|
87
|
+
|
88
|
+
1. Improve the compatibility of Validates Numericality shared examples and Each Validator shared examples.
|
89
|
+
|
90
|
+
## v2.0.2
|
91
|
+
|
92
|
+
1. Improve the Ruby Gem Specification for homepage URL.
|
93
|
+
2. Improve the Ruby Gem Specification to depend on RSpec Rails 5.x.
|
94
|
+
3. Upgrade the Gemfile.lock file.
|
95
|
+
4. Clean the un-used RSpec examples.
|
data/lib/unidom/common/rspec.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
shared_examples 'ActiveModel::EachValidator' do |valid_values, invalid_values|
|
2
2
|
|
3
3
|
mock_model_class_name = "#{described_class.name}MockModel"
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
if mock_model_class_name.deconstantize.present?
|
5
|
+
mock_model_namespace = mock_model_class_name.deconstantize.constantize
|
6
|
+
mock_model_name = mock_model_class_name.demodulize
|
7
|
+
else
|
8
|
+
mock_model_namespace = Object
|
9
|
+
mock_model_name = mock_model_class_name
|
10
|
+
end
|
11
|
+
|
7
12
|
mock_model_namespace.const_set mock_model_name, Class.new
|
8
|
-
class_instance
|
13
|
+
class_instance = mock_model_namespace.const_get mock_model_name
|
14
|
+
validator_name = described_class.to_s.underscore.chomp('_validator').to_sym
|
9
15
|
|
10
16
|
class_instance.class_eval do
|
11
17
|
include ActiveModel::Model
|
@@ -6,19 +6,41 @@ shared_examples 'scope' do |scope_name, fixtures|
|
|
6
6
|
|
7
7
|
fixtures.select { |fixture| 'E'!=fixture[:count_diff] } .each do |fixture|
|
8
8
|
describe ".#{scope_name}(#{fixture[:args].blank? ? '' : (fixture[:args].map &:inspect).join(', ')})" do
|
9
|
+
|
9
10
|
before :each do
|
10
|
-
|
11
|
+
#@count = fixture[:args].present? ? described_class.send(scope_name, *fixture[:args]).count : described_class.send(scope_name).count
|
12
|
+
if fixture[:args].present?
|
13
|
+
if fixture[:args][0].is_a? Hash
|
14
|
+
@count = described_class.send(scope_name, **fixture[:args][0]).count
|
15
|
+
else
|
16
|
+
@count = described_class.send(scope_name, *fixture[:args]).count
|
17
|
+
end
|
18
|
+
else
|
19
|
+
@count = described_class.send(scope_name).count
|
20
|
+
end
|
11
21
|
@model_instances = []
|
12
22
|
fixture[:attributes_collection].each do |attributes| @model_instances << (described_class.create! attributes) end
|
13
23
|
end
|
24
|
+
|
14
25
|
after :each do
|
15
26
|
@count = 0
|
16
27
|
@model_instances.each do |model_instance| model_instance.destroy end if @model_instances.present?
|
17
28
|
end
|
29
|
+
|
18
30
|
it "has #{fixture[:count_diff]} added" do
|
19
|
-
|
31
|
+
if fixture[:args].present?
|
32
|
+
if fixture[:args][0].is_a? Hash
|
33
|
+
actual_count = described_class.send(scope_name, **fixture[:args][0]).count
|
34
|
+
else
|
35
|
+
actual_count = described_class.send(scope_name, *fixture[:args]).count
|
36
|
+
end
|
37
|
+
else
|
38
|
+
actual_count = described_class.send(scope_name).count
|
39
|
+
end
|
40
|
+
#actual_count = fixture[:args].present? ? described_class.send(scope_name, **fixture[:args][0]).count : described_class.send(scope_name).count
|
20
41
|
expect(actual_count).to eq(fixture[:count_diff]+@count)
|
21
42
|
end
|
43
|
+
|
22
44
|
end
|
23
45
|
end
|
24
46
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
shared_examples 'validates numericality' do |model_attributes, attribute_name, options|
|
2
2
|
|
3
3
|
attribute_name = attribute_name.to_sym
|
4
|
-
presence_validator = described_class.validators.select { |v| v.is_a?(ActiveRecord::Validations::PresenceValidator)&&v.attributes.include?(attribute_name) }.first
|
5
|
-
excluded_validators = described_class.validators.select { |v| v.attributes.include?(attribute_name)&&![ ActiveRecord::Validations::PresenceValidator, ActiveModel::Validations::NumericalityValidator ].include?(v.class) }
|
4
|
+
presence_validator = described_class.validators.select { |v| (v.is_a?(ActiveModel::Validations::PresenceValidator)||v.is_a?(ActiveRecord::Validations::PresenceValidator))&&v.attributes.include?(attribute_name) }.first
|
5
|
+
excluded_validators = described_class.validators.select { |v| v.attributes.include?(attribute_name)&&![ ActiveRecord::Validations::PresenceValidator, ActiveRecord::Validations::NumericalityValidator, ActiveModel::Validations::PresenceValidator, ActiveModel::Validations::NumericalityValidator ].include?(v.class) }
|
6
6
|
|
7
7
|
if excluded_validators.present?
|
8
8
|
raise ArgumentError.new("The validators on the #{attribute_name.inspect} attribute must be PresenceValidator or NumericalityValidator. The excluded validator#{excluded_validators.size>1 ? 's are' : ' is'}: #{excluded_validators.inspect}.")
|
data/unidom-common-rspec.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = 'Unidom Common RSpec 是为 Unidom Common 设计的基于 RSpec 的共享测试用例。'
|
13
13
|
spec.description = 'Unidom Common RSpec is a RSpec-based Shared Example for the Unidom Common-based models. Unidom Common RSpec 是为 Unidom Common 设计的基于 RSpec 的共享测试用例。'
|
14
|
-
spec.homepage = 'https://
|
14
|
+
spec.homepage = 'https://gitee.com/Unidom/unidom-common-rspec'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = [ 'lib' ]
|
29
29
|
|
30
|
-
spec.add_development_dependency 'rspec-rails', '~>
|
30
|
+
spec.add_development_dependency 'rspec-rails', '~> 5.0'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
33
|
-
spec.add_development_dependency 'rake', '~>
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
34
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
35
|
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-common-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,11 +102,11 @@ files:
|
|
102
102
|
- lib/unidom/common/rspec/validates_text_shared_examples.rb
|
103
103
|
- lib/unidom/common/rspec/version.rb
|
104
104
|
- unidom-common-rspec.gemspec
|
105
|
-
homepage: https://
|
105
|
+
homepage: https://gitee.com/Unidom/unidom-common-rspec
|
106
106
|
licenses:
|
107
107
|
- MIT
|
108
108
|
metadata: {}
|
109
|
-
post_install_message:
|
109
|
+
post_install_message:
|
110
110
|
rdoc_options: []
|
111
111
|
require_paths:
|
112
112
|
- lib
|
@@ -121,8 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
125
|
-
signing_key:
|
124
|
+
rubygems_version: 3.2.3
|
125
|
+
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Unidom Common RSpec 是为 Unidom Common 设计的基于 RSpec 的共享测试用例。
|
128
128
|
test_files: []
|