added RSpec and RSpec on Rails

This commit is contained in:
Xin Zheng 2008-01-22 16:39:09 +00:00
parent ddd5b4cf19
commit 3f607d565b
316 changed files with 23828 additions and 0 deletions

View file

@ -0,0 +1,39 @@
module Spec
module Mocks
module Methods
def should_receive(sym, opts={}, &block)
__mock_proxy.add_message_expectation(opts[:expected_from] || caller(1)[0], sym.to_sym, opts, &block)
end
def should_not_receive(sym, &block)
__mock_proxy.add_negative_message_expectation(caller(1)[0], sym.to_sym, &block)
end
def stub!(sym, opts={})
__mock_proxy.add_stub(caller(1)[0], sym.to_sym, opts)
end
def received_message?(sym, *args, &block) #:nodoc:
__mock_proxy.received_message?(sym.to_sym, *args, &block)
end
def rspec_verify #:nodoc:
__mock_proxy.verify
end
def rspec_reset #:nodoc:
__mock_proxy.reset
end
private
def __mock_proxy
if Mock === self
@mock_proxy ||= Proxy.new(self, @name, @options)
else
@mock_proxy ||= Proxy.new(self, self.class.name)
end
end
end
end
end