Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

convenience method for associating your stubs with other stubs in mod…

…el definitions
  • Loading branch information...
commit ccc4392893a0f3c75e21fc6ba66825a8b4f9f43f 1 parent 287558d
@technoweenie authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/model_stubbing/model.rb
View
14 lib/model_stubbing/model.rb
@@ -104,5 +104,19 @@ def purge
def connection
@connection ||= model_class.respond_to?(:connection) && model_class.connection
end
+
+ protected
+ def method_missing(model_name, stub_name, *args)
+ named_model = @definition.models[model_name]
+ if named_model.nil?
+ raise "No #{model_name.inspect} model found when calling #{model_name}(#{stub_name})"
+ end
+ stub = named_model.stubs[stub_name]
+ if stub.nil?
+ raise "No #{stub_name.inspect} stub found in the #{model_name.inspect} model when calling #{model_name}(#{stub_name})"
+ else
+ stub
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.