spec/lib/opay/helpers/payu_helper_spec.rb in opay-1.0.0.beta vs spec/lib/opay/helpers/payu_helper_spec.rb in opay-1.0.0

- old
+ new

@@ -1,23 +1,17 @@ require 'spec_helper' module Opay describe Helpers::PayuHelper, type: :helper do - before do - # stub(request).env { {"HTTP_USER_AGENT" => "Some String"} } - end - context 'form tag' do - it 'creates form tag' do - order = Order.create! name: 'first order', amount: 1000 # 10 zł + before do + @order = Order.create! name: 'first order', amount: 1000 # 10 zł + end - # helper.payu_form_for(order) do |f| - # f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1' - # end.should be true - - html = helper.payu_form_for(order) do |f| + it 'creates form tag' do + html = helper.payu_form_for(@order) do |f| f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1' end html.should have_css('form[action="https://www.platnosci.pl/paygw/UTF/NewPayment"]') html.should have_css('form[method="post"]') @@ -32,9 +26,20 @@ html.should have_css('input[name="amount"]') html.should have_css('input[name="desc"]') html.should have_css('input[name="client_ip"]') html.should have_css('input[name="js"]') + end + + it 'works in test mode' do + Opay.config.test_mode = true + Opay.config.test_mode.should be true + + html = helper.payu_form_for(@order) do |f| + f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1' + end + + html.should have_css('input[name="pay_type"][value="t"]') end end end end