rspec-model 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rspec/model/version.rb +1 -1
- data/lib/rspec/specs.rb +35 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d18f68c0f206026dcc5b8e964b42196391e7366a3418b12aefbb0f67baab3aa
|
4
|
+
data.tar.gz: 5f06dadc0847d4299b358f21859fa6e2cde23cfd8bdd0efdfa239017d097f2da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba018cc9eb81b0e05938902a8a51dd91be2ca2ca10492dd6a0f77879f7363638967bb7ef0eeb3385e03a2bee54dfb024e25e314d7ed89812622e39484faca61
|
7
|
+
data.tar.gz: cf551f4365b3f6dc2caa58303edc324cb17182531737f90e4b3047418ae0301b4671799b7860cf103a3d52ee19d5bcb32130c0e65e0f8165e9f59703c9a094c0
|
data/Gemfile.lock
CHANGED
data/lib/rspec/model/version.rb
CHANGED
data/lib/rspec/specs.rb
CHANGED
@@ -21,6 +21,8 @@ module RSpec
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
yield if block_given?
|
24
26
|
end
|
25
27
|
|
26
28
|
def specify_factory(factory_name: nil, traits: nil, context_name: nil) # :nodoc:
|
@@ -38,6 +40,8 @@ module RSpec
|
|
38
40
|
it { is_expected.to be_valid }
|
39
41
|
end
|
40
42
|
end
|
43
|
+
|
44
|
+
yield if block_given?
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -50,7 +54,38 @@ module RSpec
|
|
50
54
|
Array.wrap(has_many).each do |association, dependent|
|
51
55
|
it { is_expected.to have_many(association).dependent(dependent) }
|
52
56
|
end
|
57
|
+
|
58
|
+
yield if block_given?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def specify_validations(presence_of: nil, length_of: nil, inclusion_of: nil, acceptance_of: nil, context_name: nil) # :nodoc:
|
63
|
+
describe context_name || 'validations' do
|
64
|
+
Array.wrap(presence_of).each do |field|
|
65
|
+
it { is_expected.to validate_presence_of field }
|
66
|
+
end
|
67
|
+
|
68
|
+
length_of&.each do |field, options|
|
69
|
+
predicate = validate_length_of field
|
70
|
+
predicate = predicate.is_at_most(options[:at_most]) if options[:at_most]
|
71
|
+
|
72
|
+
it { is_expected.to predicate }
|
73
|
+
end
|
74
|
+
|
75
|
+
inclusion_of&.each do |field, array|
|
76
|
+
it { is_expected.to validate_inclusion_of(field).in_array array }
|
77
|
+
end
|
78
|
+
|
79
|
+
Array.wrap(acceptance_of).each do |field|
|
80
|
+
it { is_expected.to validate_acceptance_of field }
|
81
|
+
end
|
82
|
+
|
83
|
+
yield if block_given?
|
53
84
|
end
|
54
85
|
end
|
86
|
+
|
87
|
+
alias test_factory_validness specify_factory
|
88
|
+
alias test_associations specify_associations
|
89
|
+
alias test_validations specify_validations
|
55
90
|
end
|
56
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- roman.strazanec
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write common specifications for the models in your Ruby on Rails application.
|
14
14
|
email:
|