database_validations 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ee6d1beb244daa4a90b9336e202f68912a3e25b55085b2459ef8e4ffea161db
4
- data.tar.gz: e266c1b54751162c0c589a2dea9fd450bfe1dde94271d91958b612b0d96282c8
3
+ metadata.gz: 0272e7610a4c92445421092f94faff13711f4b235d74340ee924b946dfe4d487
4
+ data.tar.gz: 0646b4e6bab48d3e48c4860d715e600a7f02211be18676d0c5258e33b490e1e8
5
5
  SHA512:
6
- metadata.gz: 1d98bb0b3d2b8810c60d5dabbfab6f4aa41619a1016c7d996394839822fcd61bcc2a9fbaf0c5b0502c88c76cc1cc39d16a4691b400d8dde679ce93d2bd1908a2
7
- data.tar.gz: 7e7725c739b7e708e3736497a753c6aa2b446008d2070b82d6eed859e662513dac65f77bc96d264abd3cb329ef502856aa6b529dd6e825911bb24b1ec536b003
6
+ metadata.gz: 0a475cdbd890674df1b3ed1f7f493c0426638016e5c4a20e8a5f333cb7f4d3101581a40478d45c2dedde0fea77fbdd1589a7947d8ab6c7d4f26008c829b066db
7
+ data.tar.gz: b7e63a9b639fcb81a3f7921336563d9c4cb5d68e27c27c80863ad0ed56d40977ffb9f93ba6732ef469983052f174374e30f38e42cf732833b51898ceee81f135
@@ -1,6 +1,6 @@
1
1
  # @scope Models
2
2
  #
3
- # Matches when model validate database uniqueness of some field.
3
+ # Matches when model or instance of model validates database uniqueness of some field.
4
4
  #
5
5
  # Modifiers:
6
6
  # * `with_message(message)` -- specifies a message of the error;
@@ -13,6 +13,12 @@
13
13
  # ```ruby
14
14
  # it { expect(Model).to validate_db_uniqueness_of(:field) }
15
15
  # ```
16
+ #
17
+ # is the same as
18
+ #
19
+ #```ruby
20
+ # it { expect(Model.new).to validate_db_uniqueness_of(:field) }
21
+ # ```
16
22
  RSpec::Matchers.define :validate_db_uniqueness_of do |field|
17
23
  chain(:with_message) do |message|
18
24
  @message = message
@@ -30,9 +36,11 @@ RSpec::Matchers.define :validate_db_uniqueness_of do |field|
30
36
  @index_name = index_name
31
37
  end
32
38
 
33
- match do |model|
39
+ match do |object|
34
40
  @validators = []
35
41
 
42
+ model = object.is_a?(Class) ? object : object.class
43
+
36
44
  DatabaseValidations::Helpers.each_validator(model) do |validator|
37
45
  @validators << {
38
46
  field: validator.field,
@@ -1,3 +1,3 @@
1
1
  module DatabaseValidations
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin