specstar-models 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/specstar/models.rb +9 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa3ee37cc5b4917b1bd35ea28b6f21377b7eb836
4
- data.tar.gz: bc210547f94e2e43243a7341a3f7e719f5280575
3
+ metadata.gz: 4b065846863af4226a3ab27f23beeb016cac032f
4
+ data.tar.gz: ea4bd2771757700817bd2b3396c83b850fd2164f
5
5
  SHA512:
6
- metadata.gz: c38baed49d61b30eb938b771253b4fa45cc780b5c757f1b64ecba6c68687c4b39b6eb789328a7062db2df7b6336487242d7bb116577820d0526ac1505295e071
7
- data.tar.gz: 34eeaeb8f58a0008188ccbc1fd888aa53e1dfb5b3c42baa21f9521b99d150de3183a56aad2d4c2b7ceb3ac783dbbdb76aec21f33a9e3eb83ba56730d24f03ae6
6
+ metadata.gz: 12403958e0e596f8a1661bd636a2376f45e11aa348e5f6ba25170d7f618f3543646ee61f2a130ba521a91318f25aacb13c8dc342c02e420239400c2447bf9d25
7
+ data.tar.gz: 6c7da052912ab9798776ff0b49ee9f49d49313257ea88cd5081501a047cb1dd70151f7d9a44aaaeb3a51f25a6a06efd2b7ebb62fb84aa620b134b65a383c9774
@@ -4,10 +4,6 @@ require 'rspec/expectations'
4
4
  module Specstar
5
5
  module Models
6
6
  module Matchers
7
- def properties_to_sentence(hash)
8
- " of " + hash.map { |key, value| "#{key} #{value}" }.to_sentence if hash.present?
9
- end
10
-
11
7
  def validate_presence_of_methods_in_options(model, options)
12
8
  if options[:if] && options[:if].is_a?(Symbol)
13
9
  return false unless model.respond_to? options[:if]
@@ -53,13 +49,17 @@ module Specstar
53
49
  result
54
50
  end
55
51
 
56
- failure_message_for_should do |target|
52
+ failure_message do |target|
57
53
  "Expected #{target.class} to have an attribute '#{attr}'#{properties_to_sentence @extras}."
58
54
  end
59
55
 
60
56
  description do
61
57
  "have an attribute '#{attr}'#{properties_to_sentence @extras}."
62
58
  end
59
+
60
+ def properties_to_sentence(hash)
61
+ " of " + hash.map { |key, value| "#{key} #{value}" }.to_sentence if hash.present?
62
+ end
63
63
  end
64
64
 
65
65
  def has_attribute?(model, attr, extras={})
@@ -89,7 +89,7 @@ module Specstar
89
89
  end.size > 0
90
90
  end
91
91
 
92
- failure_message_for_should do |model|
92
+ failure_message do |model|
93
93
  if has_attribute?(model, attr) || has_association?(model, attr)
94
94
  if options.nil? || validate_presence_of_methods_in_options(model, options)
95
95
  "expected #{model.class} to validate presence of #{attr}."
@@ -109,7 +109,7 @@ module Specstar
109
109
  end.size > 0
110
110
  end
111
111
 
112
- failure_message_for_should do |model|
112
+ failure_message do |model|
113
113
  if has_attribute?(model, attr) || has_association?(model, attr)
114
114
  if options.nil? || validate_presence_of_methods_in_options(model, options)
115
115
  "expected #{model.class} to validate uniqueness of #{attr}."
@@ -130,7 +130,7 @@ module Specstar
130
130
  end.size > 0
131
131
  end
132
132
 
133
- failure_message_for_should do |model|
133
+ failure_message do |model|
134
134
  if has_attribute?(model, attr) || has_association?(model, attr)
135
135
  "expected #{model.class} to validate inclusion of #{attr} in [#{options.delete(:in).map(&:to_s).join(', ')}]."
136
136
  else
@@ -149,7 +149,7 @@ module Specstar
149
149
  end.size > 0
150
150
  end
151
151
 
152
- failure_message_for_should do |model|
152
+ failure_message do |model|
153
153
  if has_attribute?(model, attr) || has_association?(model, attr)
154
154
  "expected #{model.class} to validate numericality of #{attr} in [#{options.delete(:in).map(&:to_s).join(', ')}]."
155
155
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specstar-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sujoy Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core