Sha256: 18d11d17a6086df062890c5d5c45e15ba08fd0a4a76d2a4221ca323463e148bb
Contents?: true
Size: 1.3 KB
Versions: 10
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' require 'integration/required_field_validator/spec_helper' describe 'required_field_validator/association_spec' do before :all do class ::Artist include DataMapper::Resource property :id, Serial property :name, String, :auto_validation => false has n, :albums validates_presence_of :name end class ::Album include DataMapper::Resource property :id, Serial property :name, String, :auto_validation => false property :artist_id, Integer, :index => :artist belongs_to :artist validates_presence_of :name, :artist end Artist.auto_migrate! end describe 'Album' do before do @artist = Artist.create(:name => "Oceanlab") @album = @artist.albums.new(:name => "Sirens of the sea") end describe 'with a missing artist' do before do @album.artist = nil end it 'is not valid' do @album.should_not be_valid end it 'has a meaninful error messages on association key property' do @album.valid? @album.errors.on(:artist).should == [ 'Artist must not be blank' ] end end describe 'with specified artist and name' do it 'is valid' do @album.should be_valid end end end end
Version data entries
10 entries across 10 versions & 1 rubygems