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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b5dfd97e8015044969ad11c26300b7ce7058bdfba68d6cf85c1f457f2d13c4d
4
- data.tar.gz: efe8adc439567b907aab7a7b85f9e8e3400677e099bfea4ab4cc76ebfd22113a
3
+ metadata.gz: 7d18f68c0f206026dcc5b8e964b42196391e7366a3418b12aefbb0f67baab3aa
4
+ data.tar.gz: 5f06dadc0847d4299b358f21859fa6e2cde23cfd8bdd0efdfa239017d097f2da
5
5
  SHA512:
6
- metadata.gz: 783bdbedced40f3466220717173e8663e3349a89df23048ab531868f92bb6b5c90c37e8e660424eb5bfd4351f5f0e313941d3001f1e93996f46f046a7d2d01af
7
- data.tar.gz: e2c6d66dd33fc8b7ee5652c96004905f1d32aed47d8fae6fdec8494393f1b81c9b5e3dfb8b5cc5f796153383068fdf020b8899e230c67b73c0c911dca4a9527b
6
+ metadata.gz: 7ba018cc9eb81b0e05938902a8a51dd91be2ca2ca10492dd6a0f77879f7363638967bb7ef0eeb3385e03a2bee54dfb024e25e314d7ed89812622e39484faca61
7
+ data.tar.gz: cf551f4365b3f6dc2caa58303edc324cb17182531737f90e4b3047418ae0301b4671799b7860cf103a3d52ee19d5bcb32130c0e65e0f8165e9f59703c9a094c0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-model (0.1.2)
4
+ rspec-model (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Model
5
- VERSION = "0.1.2"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
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.1.2
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-04-07 00:00:00.000000000 Z
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: