remarkable_mongoid 0.4.0 → 0.5.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.
data/README.markdown CHANGED
@@ -5,6 +5,10 @@ RSpec Matchers for Mongoid
5
5
 
6
6
  ## Matchers
7
7
 
8
+ Fields
9
+
10
+ * have_field
11
+
8
12
  Associations
9
13
 
10
14
  * reference_one
@@ -17,6 +21,7 @@ Associations
17
21
  Validations
18
22
 
19
23
  * validate_uniqueness_of
24
+ * validate_association
20
25
  * All ActiveModel validations from [Remarkable::ActiveModel](http://github.com/remarkable/remarkable/tree/master/remarkable_activemodel)
21
26
 
22
27
  ## Installation
@@ -0,0 +1,39 @@
1
+ module Remarkable::Mongoid
2
+ module Matchers
3
+ def have_field(field, options = {})
4
+ HasFieldMatcher.new(field, options)
5
+ end
6
+
7
+ class HasFieldMatcher
8
+ attr_accessor :field, :options
9
+
10
+ def initialize(field, options)
11
+ self.field = field.to_s
12
+ self.options = { :type => String }.merge(options)
13
+ end
14
+
15
+ def matches?(subject)
16
+ @subject = subject.is_a?(Class) ? subject : subject.class
17
+ @subject.fields.has_key?(field) && (@subject.fields[field].type == options[:type])
18
+ end
19
+
20
+ def description
21
+ "have field #{field} #{humanized_options}"
22
+ end
23
+
24
+ def failure_message_for_should
25
+ "expected #{@subject} to have field #{field} #{humanized_options}"
26
+ end
27
+
28
+ def failure_message_for_should_not
29
+ "expected #{@subject} to not have field #{field} #{humanized_options}"
30
+ end
31
+
32
+ private
33
+
34
+ def humanized_options
35
+ "of type #{options[:type]}"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,6 +4,7 @@ module Remarkable
4
4
  end
5
5
 
6
6
  require 'remarkable/active_model'
7
+ require 'remarkable/mongoid/fields'
7
8
  require 'remarkable/mongoid/associations'
8
9
  require 'remarkable/mongoid/validate_uniqueness_of'
9
10
  require 'remarkable/mongoid/validate_association'
@@ -16,4 +17,4 @@ elsif defined?(Spec) # RSpec 1.x
16
17
  Spec::Runner.configure do |config|
17
18
  config.include(Remarkable::Mongoid::Matchers)
18
19
  end
19
- end
20
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remarkable_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Cardarella
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-01 00:00:00 -04:00
18
+ date: 2010-10-15 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -145,6 +145,7 @@ files:
145
145
  - README.markdown
146
146
  - lib/remarkable/mongoid.rb
147
147
  - lib/remarkable/mongoid/associations.rb
148
+ - lib/remarkable/mongoid/fields.rb
148
149
  - lib/remarkable/mongoid/validate_association.rb
149
150
  - lib/remarkable/mongoid/validate_uniqueness_of.rb
150
151
  has_rdoc: true