-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel.rb
More file actions
36 lines (32 loc) · 991 Bytes
/
parallel.rb
File metadata and controls
36 lines (32 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'selenium-webdriver'
require 'yaml'
def parrallel_test
threads = []
drivers = {}
specs = YAML.load_file("specs.yml")
specs.each do |k,v|
v = v.split(' ')
threads << Thread.new do
case v.last
when 'firefox'
Thread.current[:driver] = Selenium::WebDriver.for :firefox
drivers[k] = Thread.current[:driver]
File.open('drivers.yml','w') do |fp|
fp.write drivers.to_yaml
end
yield(v.last)
when 'chrome'
Selenium::WebDriver::Chrome::Service.executable_path = File.join(Dir.pwd,'vendor/chromedriver')
Thread.current[:driver] = Selenium::WebDriver.for :chrome
drivers[k] = Thread.current[:driver]
File.open('drivers.yml','w') do |fp|
fp.write drivers.to_yaml
end
yield(v.last)
end
end
threads.each { |thread| thread.join }
end
parrallel_test do |spec|
system "rspec #{spec} "
end