Sha256: e86dcfbeecb140c38a9de44006b3cf0abf1bc80bede3ef8c6921bfa90b5d3183

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')

require 'test/unit'
require 'ostruct'

require 'og'

class TC_OgMeta < Test::Unit::TestCase # :nodoc: all
	include Og 

	# Forward declaration.

	class Comment; end
	
	class Article
		property :name, String
		property :age, Fixnum
		has_many :comments, Comment

		def initialize (name = nil, age = nil)
			@name, @age = name, age
		end
	end

	class Comment
		prop_accessor :text, String
		belongs_to :article, Article

		def initialize(text = nil)
			@text = text
		end
	end

	def setup
	end

	def teardown
	end

	def test_all
		par = Article.__meta[:props_and_relations]
		assert_equal 3, par.size
		assert_equal Property, par[1].class
		assert_equal HasMany, par[2].class

		par = Comment.__meta[:props_and_relations]
		assert_equal 3, par.size
		assert_equal Property, par[0].class
		assert_equal BelongsTo, par[1].class
		assert_equal 'article_oid', par[1].meta[:property].to_s
		assert_equal String, par[0].klass
		assert_equal Article, par[1].foreign_class
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
og-0.16.0 test/og/tc_meta.rb