lib/bogus/double.rb in bogus-0.0.2 vs lib/bogus/double.rb in bogus-0.0.3.rc.1
- old
+ new
@@ -1,10 +1,30 @@
-class Bogus::Double < BasicObject
- extend ::Bogus::Takes
- takes :object, :double, :verifies_stub_definition, :records_double_interactions
+module Bogus
+ class Double
+ extend Takes
+ include ProxiesMethodCalls
- def method_missing(name, *args, &block)
- @verifies_stub_definition.verify!(@object, name, args)
- @records_double_interactions.record(@object, name, args, &block)
- @double.__send__(name, *args, &block)
+ takes :object, :double_tracker, :verifies_stub_definition,
+ :overwrites_methods, :records_double_interactions
+
+ def stub
+ proxy(:stubs)
+ end
+
+ def stubs(name, *args, &return_value)
+ double_tracker.track(object)
+ verifies_stub_definition.verify!(object, name, args)
+ records_double_interactions.record(object, name, args, &return_value)
+ overwrites_methods.overwrite(object, name)
+ object.__shadow__.stubs(name, *args, &return_value)
+ end
+
+ def mock
+ proxy(:mocks)
+ end
+
+ def mocks(name, *args, &return_value)
+ stubs(name, *args, &return_value)
+ object.__shadow__.mocks(name, *args, &return_value)
+ end
end
end