lib/matchers/document/have_field.rb in mongoid-minitest-0.1.1 vs lib/matchers/document/have_field.rb in mongoid-minitest-0.1.2
- old
+ new
@@ -1,11 +1,9 @@
module Mongoid
module Matchers
module Document
- class HaveFieldMatcher
- include Helpers
-
+ class HaveFieldMatcher < Matcher
def initialize(*fields)
@fields = fields.collect(&:to_s)
end
def of_type(type)
@@ -24,11 +22,11 @@
@fields.each do |field|
if @klass.fields.include?(field)
error = ""
result_field = @klass.fields[field]
-
+
if check_type_with(result_field.type)
error << " of type #{result_field.type.inspect}"
end
if check_default_with(result_field.default_val)
@@ -60,14 +58,14 @@
desc << " with default value of #{@default.inspect}" if !@default.nil?
desc
end
private
-
+
def check_type_with(type)
@type && type != @type
end
-
+
def check_default_with(default)
!@default.nil? && !default.nil? && default != @default
end
end