I have a test which needs to check if a block given to a method is being called.
block = lambda {
#some stuff
}
block.should_receive(:call)
get_data_with_timeout(1, &block)
def get_data_with_timeout(timeout)
begin
timeout(timeout) {
data = get_data
yield data #do stuff
}
rescue Timeout::Error
#timeout!
end
end
Essentially I want to check that if there is no timeout then the block is being called and visa versa. Is this possible in rspec?