test/app.rb in sinatra-paypal-0.2.0 vs test/app.rb in sinatra-paypal-0.3.0
- old
+ new
@@ -2,10 +2,11 @@
require 'bundler'
Bundler.require
require 'sinatra'
require 'sinatra/paypal'
+require 'fileutils'
# this allows us to handle errors in test without the default page
# getting generated (which isn't very useful inside unit-tests)
set :raise_errors, false
set :show_exceptions, false
@@ -17,18 +18,21 @@
return "#{e.class}: #{e.message}" unless e.nil?
return "unknown error"
end
payment :repeated? do |p|
- path = '/tmp/test.sinatra-payment.log'
+ path = 'test.sinatra-payment.log'
+ path = File.join '/tmp', path if !Gem.win_platform?
+ FileUtils.touch path if !File.exist? path
+
data = File.read path
id = "#{p.id}\n"
if data.include? id
- true
+ return true
else
File.append path, "#{p.id}\n"
- false
+ return false
end
end
get '/payment/form/empty' do
return html_payment_form nil