shoulda_macros/units.rb
##
#  Asserts that model has accept_nested_attribtues_for defined for specific models.
#
#    should_accept_nested_attributes_for :foo, :bar 
#
Asserts that model has accept_nested_attribtues_for defined for specific models.
Asserts that model has accept_nested_attribtues_for defined for specific models .
def should_accept_nested_attributes_for(*attr_names)
      klass = self.name.gsub(/Test$/, '').constantize
      context "#{klass}" do
        attr_names.each do |association_name|
          should "accept nested attrs for #{association_name}" do
            meth = "#{association_name}_attributes="
            assert  ([meth,meth.to_sym].any?{ |m| klass.instance_methods.include?(m) }),
                    "#{klass} does not accept nested attributes for #{association_name}"
          end
        end
      end
    end
def should_accept_nested_attributes_for ( * attr_names ) klass = self . name . gsub ( / Test$ / , '' ) . constantize context "#{klass}" do attr_names . each do | association_name | should "accept nested attrs for #{association_name}" do meth = "#{association_name}_attributes=" assert ( [ meth , meth . to_sym ] . any? { | m | klass . instance_methods . include? ( m ) } ) , "#{klass} does not accept nested attributes for #{association_name}" end end end end
Asserts that model has accept_nested_attribtues_for defined for specific models.
Asserts that model has accept_nested_attribtues_for defined for specific models .
attr_names