Sha256: 40b28e9bf5d44a831a697981f93bfdd84c5a854f9968e741a3daaa6587428fcb

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../helper')

class TestAccountModelGenerator < Test::Unit::TestCase
  def setup
    @apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
    `mkdir -p #{@apptmp}`
  end

  def teardown
    `rm -rf #{@apptmp}`
  end
  
  # COUCHREST
  context 'account model using couchrest' do
    setup do
      silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=couchrest') }
      silence_logger { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
      
      @model = "#{@apptmp}/sample_project/admin/models/account.rb"
    end
    
    should 'be a couchrest model instance' do
      assert_match_in_file(/class Account < CouchRest::Model::Base/m, @model)
    end
    
    should 'not require additional validations' do
      assert_no_match_in_file(/include CouchRest::Validation/m, @model)
    end
    
    should 'no longer have validates_with_method' do
      assert_no_match_in_file(/validates_with_method/m, @model)
    end
    
    should 'validate report errors using ActiveModel errors method' do
      assert_match_in_file(/errors\.add\(:email, "is not unique"\)/m, @model)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
padrino-admin-0.10.2 test/generators/test_account_model_generator.rb
padrino-admin-0.10.1 test/generators/test_account_model_generator.rb
padrino-admin-0.10.0 test/generators/test_account_model_generator.rb