@@ -1,6 +1,6 @@ | |||||
#!make | #!make | ||||
test: | test: | ||||
ruby app.rb | |||||
bin/poke | |||||
test-visible: | test-visible: | ||||
ruby app.rb visible | |||||
bin/poke visible |
@@ -1,62 +0,0 @@ | |||||
#!/usr/bin/ruby | |||||
require 'watir' | |||||
require 'watir-scroll' | |||||
require 'zeitwerk' | |||||
loader = Zeitwerk::Loader.new | |||||
loader.push_dir __dir__ | |||||
loader.setup | |||||
# @brief main | |||||
# | |||||
# @param argv: Array | |||||
# @param argc: Integer | |||||
# | |||||
# @return ? | |||||
# @since 0.1 | |||||
# | |||||
# @todo let the developer provide the list of tests that are ran | |||||
def main argv = [], argc | |||||
if argv.include? '--server' | |||||
Server.run! | |||||
return false | |||||
end | |||||
Thread.new { | |||||
Server.run! | |||||
} | |||||
Thread.new { | |||||
Fx::pipe({ headless: ARGV.first != 'visible', | |||||
options: { | |||||
args: [ 'start-fullscreen' ] | |||||
} | |||||
}, | |||||
-> (opts) { | |||||
Watir::Browser.new :chrome, | |||||
opts | |||||
}, | |||||
-> (b) { | |||||
Watir.default_timeout = 10 | |||||
b.window.resize_to 1366, 768 | |||||
[ | |||||
Tests::ProjectNameHere::Basic | |||||
].each do |c| | |||||
c.methods(false).sort.each do |m| | |||||
if "assert" != m[0..5] | |||||
next | |||||
end | |||||
Fx::perform c.method(m), b, "#{c}::#{m}" | |||||
end | |||||
end | |||||
Server.stop! | |||||
}) | |||||
}.join | |||||
end | |||||
main ARGV, ARGV.count |
@@ -0,0 +1,69 @@ | |||||
#!/usr/bin/ruby | |||||
require 'watir' | |||||
require 'watir-scroll' | |||||
require 'zeitwerk' | |||||
loader = Zeitwerk::Loader.new | |||||
loader.push_dir __dir__.concat '/../lib' | |||||
loader.push_dir Dir.pwd.concat '/pokes' | |||||
loader.setup | |||||
# @brief main | |||||
# | |||||
# @param argv: Array | |||||
# @param argc: Integer | |||||
# | |||||
# @return ? | |||||
# @since 0.1 | |||||
# | |||||
# @todo let the developer provide the list of tests that are ran | |||||
def main argv = [], argc | |||||
if argv.include? '--server' | |||||
Server.run! | |||||
return false | |||||
end | |||||
Thread.new { | |||||
Server.run! | |||||
} | |||||
Thread.new { | |||||
Fx::pipe( | |||||
{ headless: ARGV.first != 'visible', | |||||
options: { | |||||
args: [ 'start-fullscreen' ] | |||||
} | |||||
}, | |||||
-> (opts) { | |||||
Watir::Browser.new :firefox, | |||||
opts | |||||
}, | |||||
-> (b) { | |||||
Watir.default_timeout = 10 | |||||
b.window.resize_to 1366, 768 | |||||
Tests.constants.each do |c| | |||||
k = Tests.const_get(c) | |||||
if !(k.is_a? Class) | |||||
next | |||||
end | |||||
k.methods(false).sort.each do |m| | |||||
if "assert" != m[0..5] | |||||
next | |||||
end | |||||
Fx::perform k.method(m), b, "#{c}::#{m}" | |||||
end | |||||
end | |||||
# todo: if Server.running? | |||||
Server.stop! | |||||
}) | |||||
}.join | |||||
end | |||||
main ARGV, ARGV.count |
@@ -3,6 +3,10 @@ require 'haml' | |||||
class Routes < Sinatra::Base | class Routes < Sinatra::Base | ||||
set :views, Proc.new{ | |||||
File.join root, '/../', 'pokes', 'views' | |||||
} | |||||
get 'custom/routes' do | get 'custom/routes' do | ||||
return 'hello world' | return 'hello world' | ||||
end | end |
@@ -18,7 +18,7 @@ class Server < Routes | |||||
'http://localhost:4567/proxied', | 'http://localhost:4567/proxied', | ||||
{ 'Accept' => 'text/html' } | { 'Accept' => 'text/html' } | ||||
end | end | ||||
get '/api/json/masked' do | get '/api/json/masked' do | ||||
puts request.env['HTTP_AUTHORIZATION'] | puts request.env['HTTP_AUTHORIZATION'] | ||||
return '{"result":"masked"}' | return '{"result":"masked"}' | ||||
@@ -41,7 +41,7 @@ class Server < Routes | |||||
} | } | ||||
}) | }) | ||||
end | end | ||||
get '/upload' do | get '/upload' do | ||||
haml :upload | haml :upload | ||||
end | end | ||||
@@ -59,11 +59,10 @@ class Server < Routes | |||||
-> (t) { | -> (t) { | ||||
t.each { |f| File.delete f } | t.each { |f| File.delete f } | ||||
haml :uploads, { | haml :uploads, { | ||||
locals: { | |||||
data: t | |||||
} | |||||
} | |||||
locals: { | |||||
data: t | |||||
} | |||||
} | |||||
}) | }) | ||||
end | |||||
end | |||||
end | end |
@@ -0,0 +1,12 @@ | |||||
Gem::Specification.new do |s| | |||||
s.name = 'pokes' | |||||
s.version = '0.0.1' | |||||
s.platform = Gem::Platform:RUBY | |||||
s.summary = 'e2e tests, API-first' | |||||
s.description = 'FP browser automation, pessimistic testing, HAML proxies' | |||||
s.authors = ['Luka Licina'] | |||||
s.email = ['licina.luka@outlook.com'] | |||||
s.license = 'MIT' | |||||
s.files = Dir.glob('{lib,bin}/**/*') | |||||
s.require_path = 'lib' | |||||
end |
@@ -1,4 +1,4 @@ | |||||
module Tests::ProjectNameHere | |||||
module Tests | |||||
class Basic | class Basic | ||||
# @return bool | # @return bool |