lib/matchers/associations.rb in mongoid-rspec-1.6.0 vs lib/matchers/associations.rb in mongoid-rspec-1.7.0

- old
+ new

@@ -55,10 +55,16 @@ @association[:index] = true @expectation_message << " which specifies index as #{@association[:index].to_s}" self end + def with_autobuild + @association[:autobuild] = true + @expectation_message << " which specifies autobuild as #{@association[:autobuild].to_s}" + self + end + def stored_as(store_as) raise NotImplementedError, "`references_many #{@association[:name]} :stored_as => :array` has been removed in Mongoid 2.0.0.rc, use `references_and_referenced_in_many #{@association[:name]}` instead" end def with_foreign_key(foreign_key) @@ -115,9 +121,18 @@ if metadata.autosave != true @negative_result_message = "#{@positive_result_message} which did not set autosave" return false else @positive_result_message = "#{@positive_result_message} which set autosave" + end + end + + if @association[:autobuild] + if metadata.autobuilding? != true + @negative_result_message = "#{@positive_result_message} which did not set autobuild" + return false + else + @positive_result_message = "#{@positive_result_message} which set autobuild" end end if @association[:index] if metadata.index != true