lib/mspec/mocks/proxy.rb in mspec-1.5.17 vs lib/mspec/mocks/proxy.rb in mspec-1.5.18
- old
+ new
@@ -5,10 +5,11 @@
end
def method_missing(sym, *args, &block)
@null ? self : super
end
+ private :method_missing
end
class NumericMockObject < Numeric
def initialize(name, options={})
@name = name
@@ -21,10 +22,33 @@
def singleton_method_added(val)
end
end
+class MockIntObject
+ def initialize(val)
+ @value = val
+ @calls = 0
+
+ key = [self, :to_int]
+
+ Mock.objects[key] = self
+ Mock.mocks[key] << self
+ end
+
+ attr_reader :calls
+
+ def to_int
+ @calls += 1
+ @value
+ end
+
+ def count
+ [:at_least, 1]
+ end
+end
+
class MockProxy
attr_reader :raising, :yielding
def initialize(type=nil)
@multiple_returns = nil
@@ -103,10 +127,11 @@
end
def with(*args)
raise ArgumentError, "you must specify the expected arguments" if args.empty?
@arguments = *args
- if (behaves_like_ruby_1_9 = *[])
+ behaves_like_ruby_1_9 = *[]
+ if (behaves_like_ruby_1_9)
@arguments = @arguments.first if @arguments.length <= 1
end
self
end