opensupports/tests/libs.rb

34 lines
751 B
Ruby
Raw Normal View History

2016-08-04 22:18:42 +02:00
$agent = Mechanize.new
2016-05-05 04:25:01 +02:00
def request(path, data = {})
2016-08-04 06:37:23 +02:00
uri = 'http://localhost:8080' + path
2016-08-04 22:18:42 +02:00
response = $agent.post(uri, data)
2016-05-05 04:25:01 +02:00
return JSON.parse(response.body)
end
class Database
def initialize()
mysqlUser = ENV['MYSQL_USER'] || 'root'
mysqlPass = ENV['MYSQL_PASSWORD'] || ''
@connection = Mysql.new('localhost', mysqlUser , mysqlPass, 'development')
end
2016-05-05 04:25:01 +02:00
def close()
@connection.close
end
2016-05-05 04:25:01 +02:00
def getRow(table, value, field = 'id')
queryResponse = @connection.query("select * from #{table} where #{field}='#{value.to_s}'")
return queryResponse.fetch_hash
end
2016-05-05 04:25:01 +02:00
end
$database = Database.new
$staff = {
:email => 'staff@opensupports.com',
:password => 'staff'
}