Skip to content

Instantly share code, notes, and snippets.

@chanks
Created May 28, 2012 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanks/2820828 to your computer and use it in GitHub Desktop.
Save chanks/2820828 to your computer and use it in GitHub Desktop.
Sequel nested attributes spec
it "should support creating new objects with composite primary keys" do
a = @Artist.new({:name=>'Ar', :concerts_attributes=>[{:tour => 'To', :date => "2004-04-05"}]})
@db.sqls.should == []
a.save
check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
["INSERT INTO concerts (tour, date, artist_id) VALUES ('To', '2004-04-05', 1)",
"INSERT INTO concerts (artist_id, tour, date) VALUES (1, 'To', '2004-04-05')"
]) # etc.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment