lib/matchers/indexes.rb in mongoid-rspec-1.10.0 vs lib/matchers/indexes.rb in mongoid-rspec-1.11.0
- old
+ new
@@ -11,17 +11,16 @@
end
def matches?(klass)
@klass = klass.is_a?(Class) ? klass : klass.class
@errors = []
-
unless @klass.index_options[@index_fields]
@errors.push "no index for #{@index_fields}"
else
if !@options.nil? && !@options.empty?
@options.each do |option, option_value|
- if @klass.index_options[@index_fields][option] != option_value
+ if denormalising_options(@klass.index_options[@index_fields])[option] != option_value
@errors.push "index for #{@index_fields.inspect} with options of #{@klass.index_options[@index_fields].inspect}"
end
end
end
end
@@ -40,9 +39,22 @@
def description
desc = "have an index for #{@index_fields.inspect}"
desc << " with options of #{@options.inspect}" if @options
desc
end
+
+ private
+ MAPPINGS = {
+ dropDups: :drop_dups
+ }
+
+ def denormalising_options(opts)
+ options = {}
+ opts.each_pair do |option, value|
+ options[MAPPINGS[option] || option] = value
+ end
+ options
+ end
end
def have_index_for(index_fields)
HaveIndexForMatcher.new(index_fields)
end