I need to write that a new object will be created in the payment system. Code included from order.rband order_spec.rb( Orderclass here ):
def confirm_order(method_of_payment)
if credit_card_but_products_out_stock?(method_of_payment)
raise "Cannot make credit card payment now, as some products are out of stock"
end
order_total
Payment.new(method_of_payment, self.total)
end
it 'it creates a new payment object if method_of_payment is valid and order.total is > 0' do
order.add_product(product, 3)
order.confirm_order(:credit_card)
end
I want to understand how I can write an appropriate specification to verify that a new Payment object has been created. I found this article from Semaphore CI useful, but I'm not sure about the solution. I am pretty sure that I need to create a double test version, and then maybe the stub to method allow(order).to receive(:confirm_order).and_return(#new_object??).
source
share