lib/matchers/associations.rb in mongoid-rspec-4.1.0 vs lib/matchers/associations.rb in mongoid-rspec-4.2.0

- old
+ new

@@ -117,10 +117,16 @@ @association[:counter_cache] = true @expectation_message << " which specifies counter_cache as #{@association[:counter_cache]}" self end + def with_touch(touch = true) + @association[:touch] = touch + @expectation_message << " which specifies touch as #{@association[:touch]}" + self + end + def with_optional @association[:optional] = true @expectation_message << " which specifies optional as #{@association[:optional]}" self end @@ -267,9 +273,18 @@ if metadata.counter_cached? != true @negative_result_message = "#{@positive_result_message} which did not set counter_cache" return false else @positive_result_message = "#{@positive_result_message} which set counter_cache" + end + end + + unless @association[:touch].nil? + if metadata.options[:touch] != @association[:touch] + @negative_result_message = "#{@positive_result_message} which sets touch as #{metadata.options[:touch].inspect}" + return false + else + @positive_result_message = "#{@positive_result_message} which sets touch as #{metadata.options[:touch].inspect}" end end if @association[:optional] if metadata.options[:optional] != true