Sha256: df6d94876bd076b59b9c0bdcaf6ec2e7083392c6f33742e4aedf6e4114bde887
Contents?: true
Size: 624 Bytes
Versions: 21
Compression:
Stored size: 624 Bytes
Contents
require File.expand_path("./helper", File.dirname(__FILE__)) class User < Ohm::Model collection :posts, :Post end class Post < Ohm::Model reference :user, :User end setup do u = User.create p = Post.create(:user => u) [u, p] end test "basic shake and bake" do |u, p| assert u.posts.include?(p) p = Post[p.id] assert_equal u, p.user end test "memoization" do |u, p| # This will read the user instance once. p.user assert_equal p.user, p.instance_variable_get(:@_memo)[:user] # This will un-memoize the user instance p.user = u assert_equal nil, p.instance_variable_get(:@_memo)[:user] end
Version data entries
21 entries across 21 versions & 1 rubygems