Skip to content
Browse files

Added create_<stub> shortcut

Signed-off-by: rick <technoweenie@gmail.com>
  • Loading branch information...
1 parent 6bc00b4 commit 6090cee9e59578783f3927375ea2773ce05a133e @lawrencepit lawrencepit committed with Sep 30, 2008
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/model_stubbing/model.rb
View
3 lib/model_stubbing/model.rb
@@ -84,7 +84,8 @@ def retrieve_record(key, attributes = {})
def stub_method_definition
"def #{@plural}(key, attrs = {}) self.class.definition.models[#{@plural.inspect}].retrieve_record(key, attrs) end\n
def new_#{@singular}(key = :default, attrs = {}) key, attrs = :default, key if key.is_a?(Hash) ; #{@plural}(key, attrs.merge(:id => :new)) end\n
- def new_#{@singular}!(key = :default, attrs = {}) key, attrs = :default, key if key.is_a?(Hash) ; #{@plural}(key, attrs.merge(:id => :dup)) end"
+ def new_#{@singular}!(key = :default, attrs = {}) key, attrs = :default, key if key.is_a?(Hash) ; #{@plural}(key, attrs.merge(:id => :dup)) end\n
+ def create_#{@singular}(key = :default, attrs = {}) stub = new_#{@singular}(key, attrs) ; stub.save! ; stub end"
end
def inspect

0 comments on commit 6090cee

Please sign in to comment.
Something went wrong with that request. Please try again.