Sha256: 9bf3aeeb8657c35cf762431ce19664d1d6806fd5e769702f733d922b76423c9a
Contents?: true
Size: 589 Bytes
Versions: 15
Compression:
Stored size: 589 Bytes
Contents
require_relative "helper" 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
15 entries across 15 versions & 3 rubygems