Permalink
Browse files

updated tests

  • Loading branch information...
brantwedel committed Mar 17, 2014
1 parent 5f78ef7 commit 955e43ec403bbb18516a30866421ed2076203c18
Showing with 33 additions and 8 deletions.
  1. +1 −1 Gemfile.lock
  2. +1 −1 lib/yaddl.rb
  3. +31 −6 test/yaddl_test.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
yaddl (0.0.5)
yaddl (0.0.6)
rails (~> 4.0.0)
GEM
View
@@ -109,7 +109,7 @@ def scaffolds(options = "")
model['code']['after'] ||= []
model['code']['controller'] ||= []
sc = "rails g model #{name} " + model['attributes'].map{ |k,v| k + ':' + v['type'].sub(/yaml|hash|object|cache/i,"text") }.join(' ') + " " + model['belongs_to'].map{ |k,v| k + ':references' + (v['polymorphic'] ? "{polymorphic}" : "") }.join(' ')
puts("migration: cd #{Rails::root} && #{sc} --skip")# unless @quiet
puts("migration: cd #{Rails::root} && #{sc} --skip --no-test-framework") unless @quiet
`cd #{Rails::root} && #{sc} --skip --no-test-framework`
end if options.include?("--migrations-only")
View
@@ -9,15 +9,21 @@ class YaddlTest < ActiveSupport::TestCase
y = Yaddl::Generator.new
y.markup = "TestModel(name:string)
=to_s{name}
*RelatedModel"
*ChildModel
+RelatedModel
ReferencedModel"
y.generate("--no-scaffolds --quiet")
y.generate("--migrations-only --quiet")
assert_file "app/models/test_model.rb", "class TestModel < ActiveRecord::Base
has_many :related_models, dependent: :destroy
belongs_to :related_model
has_one :referenced_model, dependent: :destroy
has_many :child_models, dependent: :destroy
attr_accessible :related_model_id
attr_accessible :name
accepts_nested_attributes_for :related_models
accepts_nested_attributes_for :referenced_model
accepts_nested_attributes_for :child_models
# returns: string
def to_s
@@ -27,9 +33,8 @@ def to_s
"
assert_file "app/models/related_model.rb", "class RelatedModel < ActiveRecord::Base
belongs_to :test_model
has_many :test_models, dependent: :nullify
attr_accessible :test_model_id
end
"
@@ -45,11 +50,31 @@ def to_s
returns: string
getter: name
has_many:
related_models:
child_models:
dependent: destroy
class_names:
- ChildModel
belongs_to:
related_model:
class_names:
- RelatedModel
has_one:
referenced_model:
dependent: destroy
class_names:
- ReferencedModel
ChildModel:
belongs_to:
test_model:
class_names:
- TestModel
RelatedModel:
has_many:
test_models:
dependent: nullify
class_names:
- RelatedModel
ReferencedModel:
belongs_to:
test_model:
class_names:

0 comments on commit 955e43e

Please sign in to comment.