Sha256: cb8160a9093f4532baee54a5035ef752c9c5d8371c4a0c12cd5051c7d2acee8a

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# -*- encoding : utf-8 -*-
Testing Dao::Form do
  testing '.new' do
    form = new_form() 
    form = new_named_form() 
  end

  testing 'name_for' do
    assert{ Dao::Form.name_for(:foo, :a, :b) == 'dao[foo][a.b]' }
    assert{ new_form.name_for(:a, :b) == 'dao[form][a.b]' }
    assert{ new_named_form.name_for(:a, :b) == 'dao[name][a.b]' }
    assert{ new_named_form(:foo).name_for(:a, :b) == 'dao[foo][a.b]' }
  end

protected
  def new_form
    assert{ Dao::Form.new }
  end

  def new_named_form(name = 'name')
    object = Object.new
    class << object
      %w[ name attributes errors ].each{|attr_name| attr_accessor(attr_name)}
      attr_accessor :name
    end
    object.name = name
    object.attributes = Map.new
    object.errors = Dao::Errors.new
    assert{ Dao::Form.new(object) }
  end
end



BEGIN {
  testdir = File.dirname(File.expand_path(__FILE__))
  rootdir = File.dirname(testdir)
  libdir = File.join(rootdir, 'lib')

  require File.join(libdir, 'dao')
  require File.join(testdir, 'testing')
  require File.join(testdir, 'helper')
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dao-4.4.4 test/form_test.rb
dao-4.4.2 test/form_test.rb