true_automation 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/true_automation/client.rb +67 -0
- data/lib/true_automation/driver/capybara.rb +34 -0
- data/lib/true_automation/dsl.rb +1 -1
- data/lib/true_automation/helpers.rb +1 -1
- data/lib/true_automation/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad9533605c7a55ad8e9528f286a5968967617ecc
|
4
|
+
data.tar.gz: f1f1ee18fdc71fbe0d3e69f46e0e71f67621b1f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82bf853bbeb06701deecb8aad1bf6179741d28e473c8a0bcb24582a587d08355a8f16c79a4aecea9bf3fdac63ae898f676e0f75f5f3e0d03b63fcc83497b389d
|
7
|
+
data.tar.gz: '02258e95a4cdcf96c3df1a2cbb65019b51b1719fe8fd04c5e0b0ea805bc11d1607cc7b944a9a399d122a6485a602f7adcca1455f68872e02462047ae3e98a544'
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module TrueAutomation
|
5
|
+
class Client
|
6
|
+
@pid = nil
|
7
|
+
|
8
|
+
def start
|
9
|
+
begin
|
10
|
+
node_ver = `node -v`
|
11
|
+
node_ver = node_ver[1..-1]
|
12
|
+
node_versions = node_ver.split('.')
|
13
|
+
major_version = node_versions[0]
|
14
|
+
|
15
|
+
if major_version.to_i < 9
|
16
|
+
puts "Node version #{node_ver} found. TrueAutomation.IO requires Node 9+ to run."
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
rescue e
|
20
|
+
puts 'Node executable can not be found. node version 9+ is required to run TrueAutomation.IO tests.'
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
trueautomation_version = `trueautomation --version`
|
26
|
+
|
27
|
+
puts "TrueAutomation.IO client #{trueautomation_version.strip}"
|
28
|
+
rescue e
|
29
|
+
puts 'TrueAutomation.IO npm package is not installed. Run `npm install -g trueautomation` to install it first.'
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
|
33
|
+
Dir.mkdir('log') unless File.exist?('log')
|
34
|
+
|
35
|
+
logfile = "log/trueautomation-#{Time.now.strftime('%Y%m%dT%H%M%S')}.log"
|
36
|
+
|
37
|
+
@pid = spawn('trueautomation start', out: logfile)
|
38
|
+
|
39
|
+
puts "Started TrueAutomation.IO client with pid #{@pid}"
|
40
|
+
|
41
|
+
@pid
|
42
|
+
end
|
43
|
+
|
44
|
+
def stop
|
45
|
+
if @pid
|
46
|
+
puts "Stopping TrueAutomation.IO Client with pid #{@pid}"
|
47
|
+
Process.kill('TERM', @pid)
|
48
|
+
@pid = nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def wait_until_start
|
53
|
+
counter = 0
|
54
|
+
loop do
|
55
|
+
break if check_connection or counter >= 10
|
56
|
+
counter += 1
|
57
|
+
sleep 2
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def check_connection
|
64
|
+
Socket.tcp('localhost', 9515, connect_timeout: 2) { true } rescue false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../client'
|
2
|
+
|
3
|
+
module TrueAutomation
|
4
|
+
module Driver
|
5
|
+
class Capybara < Capybara::Selenium::Driver
|
6
|
+
def initialize(app, **options)
|
7
|
+
super(app, options)
|
8
|
+
|
9
|
+
@ta_client = TrueAutomation::Client.new
|
10
|
+
|
11
|
+
@options.merge!({browser: :remote,
|
12
|
+
url: 'http://localhost:9515/',
|
13
|
+
desired_capabilities: {
|
14
|
+
browser: :chrome
|
15
|
+
}})
|
16
|
+
end
|
17
|
+
|
18
|
+
def browser
|
19
|
+
unless @browser
|
20
|
+
@ta_client.start
|
21
|
+
|
22
|
+
@ta_client.wait_until_start
|
23
|
+
|
24
|
+
at_exit do
|
25
|
+
@ta_client.stop
|
26
|
+
end
|
27
|
+
|
28
|
+
super
|
29
|
+
end
|
30
|
+
@browser
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/true_automation/dsl.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: true_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TrueAutomation.IO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,6 +88,8 @@ files:
|
|
88
88
|
- bin/console
|
89
89
|
- bin/setup
|
90
90
|
- lib/true_automation.rb
|
91
|
+
- lib/true_automation/client.rb
|
92
|
+
- lib/true_automation/driver/capybara.rb
|
91
93
|
- lib/true_automation/dsl.rb
|
92
94
|
- lib/true_automation/helpers.rb
|
93
95
|
- lib/true_automation/rspec.rb
|