Sha256: 1f2c0faf8d169d40e41d734224636aa4fbfc298b4e6d9e004b1d88ee489757a9
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb") describe 'has_many relationships', :has_many => true do before :each do Redis.new.flushall Ampere.connect # These are used by the has_one/belongs_to example below class Car < Ampere::Model field :make field :model field :year has_many :passengers end class Passenger < Ampere::Model field :name field :seat belongs_to :car end @car = Car.create :make => "Lamborghini", :model => "Countach", :year => "1974" @driver = Passenger.create :name => "Max", :seat => "driver" @passenger = Passenger.create :name => "Leila", :seat => "passenger" end ### it 'should define the necessary methods for has_many relationships' do # Attr accessors @car.should respond_to(:passengers) @car.should respond_to(:"passengers=") end it 'should be able to add items to has_many relationships' do @car.passengers = @car.passengers + [@driver] @car.passengers = @car.passengers + [@passenger] @car.save @car.reload @driver.reload @passenger.reload @car.passengers.should include(@driver) @car.passengers.should include(@passenger) end it 'should be able to remove items from has_many relationships' do pending end it 'should be able to query has_many relationships' do pending end ### after :all do Ampere.disconnect Redis.new.flushall end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ampere-0.1.3 | spec/models/relationships/has_many_spec.rb |
ampere-0.1.2 | spec/models/relationships/has_many_spec.rb |
ampere-0.1.0 | spec/models/relationships/has_many_spec.rb |