Skip to content

Instantly share code, notes, and snippets.

@carllerche
Created October 28, 2009 05:11
Show Gist options
  • Save carllerche/220258 to your computer and use it in GitHub Desktop.
Save carllerche/220258 to your computer and use it in GitHub Desktop.
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Koios::Relationship" do
model :Owner do |sql|
has n, :things, :model => 'Thing', :on => :owner_id
end
model :Thing do |sql|
property :owner_id, Integer
sql << "owner_id integer"
end
before :all do
6.times do |i|
o = Owner.create
6.times { Thing.create :owner_id => o.id }
end
end
describe "#has" do
describe "n" do
before :all do
@relation = Owner.get(1).things
@expected = (1..6).map { |i| Thing.get(i) }
end
it_should_behave_like 'A public Relation'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment