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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d70d37175ba346864ba424d243f4b5e3f218b11
4
- data.tar.gz: 66b4f5bfb527b47227c22c05a27a7f3736d24caa
3
+ metadata.gz: ad9533605c7a55ad8e9528f286a5968967617ecc
4
+ data.tar.gz: f1f1ee18fdc71fbe0d3e69f46e0e71f67621b1f2
5
5
  SHA512:
6
- metadata.gz: 7f45f020ed106d5d622ce870ea5b16caecfba6ce69cf6cc3ea66011ff4c1a539981b882b242de131e4f046e4b68d0dc2a8304c7b7fdac7960adc1d704309efc0
7
- data.tar.gz: 05160e0aeb806872464410f085a089df63839b4bac3641adb92ff6abf457c2db595b9114b502c42238693a14c632c6a201cde487acd868f611eac8dc66a05f10
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
@@ -12,4 +12,4 @@ module TrueAutomation
12
12
  end
13
13
 
14
14
  extend(TrueAutomation::DSL)
15
- end
15
+ end
@@ -25,7 +25,7 @@ module TrueAutomation
25
25
  # @return [String] TrueAutomation.IO locator
26
26
  #
27
27
  def self.ta(name, locator = '')
28
- if locator.empty?
28
+ if !locator.empty?
29
29
  "#{locator}__ta__#{name}__ta__"
30
30
  else
31
31
  "__taonly__#{name}__taonly__"
@@ -1,3 +1,3 @@
1
1
  module TrueAutomation
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.4'
3
3
  end
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.2
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-14 00:00:00.000000000 Z
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