Sha256: 8048df4cd31b667bf59baffbe39f992b9ec6920a4a5b8e15320af3692b2b97fe

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

module Census
  module Shoulda

    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_act_as_list
      klass = self.name.gsub(/Test$/, '').constantize

      context "To support acts_as_list" do
        should_have_db_column('position', :type => :integer)
      end

      should "include ActsAsList methods" do
        assert klass.include?(ActsAsList::InstanceMethods)
      end

      should_have_instance_methods :acts_as_list_class, :position_column, :scope_condition
    end

  end
end

Test::Unit::TestCase.extend(Census::Shoulda)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
census-0.5.2 shoulda_macros/census.rb
census-0.5.0 shoulda_macros/census.rb
census-0.4.4 shoulda_macros/census.rb
census-0.4.3 shoulda_macros/census.rb
census-0.4.2 shoulda_macros/census.rb
census-0.4.1 shoulda_macros/census.rb
census-0.4.0 shoulda_macros/census.rb
census-0.3.1 shoulda_macros/census.rb
census-0.3.0 shoulda_macros/census.rb
census-0.2.1 shoulda_macros/census.rb
census-0.2.0 shoulda_macros/census.rb
census-0.1.0 shoulda_macros/census.rb