现在我断言调用了一个方法:
代码:
def MyClass
def send_report
...
Net::SFTP.start(@host, @username, :password => @password) do |sftp|
...
end
...
end
end
测试:
it 'successfully sends file' do
Net::SFTP.
should_receive(:start).
with('bla.com', 'some_username', :password => 'some_password')
my_class.send_report
end
但是,我还想在调用 Net::SFTP.start 时检查给定条件是否为真。我该怎么做这样的事情?
it 'successfully sends file' do
Net::SFTP.
should_receive(:start).
with('bla.com', 'some_username', :password => 'some_password').
and(<some condition> == true)
my_class.send_report
end