test/machine_test.rb in aub-machine-1.0.1 vs test/machine_test.rb in aub-machine-1.0.2
- old
+ new
@@ -264,6 +264,29 @@
should 'be able to set values using the sequence' do
assert_equal 'title-1', Machine(:article).title
end
end
+ context 'with blocks on create' do
+ setup do
+ Machine.define :article do |article, machine|
+ article.title = 'aha'
+ end
+ end
+
+ should 'use a passed block in create to initialize objects' do
+ article = Machine.build(:article) do |article|
+ article.title = 'heck'
+ end
+ assert_equal 'heck', article.title
+ end
+
+ should 'use a passed block when creating with build!' do
+ article = Machine.build!(:article) do |article|
+ article.title = 'fun'
+ assert article.new_record?
+ end
+ assert_equal 'fun', article.title
+ assert !article.new_record?
+ end
+ end
end