Skip to content

Commit 3365aff

Browse files
committed
updated bugs and binary path issue
1 parent 858be92 commit 3365aff

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ gem install browserstack-local
3434
* `localIdentifier`: If doing simultaneous multiple local testing connections, set this uniquely for different processes
3535
* `hosts`: List of hosts and ports where Local must be enabled for eg. localhost,3000,1,localhost,3001,0
3636
* `logfile`: Path to file where Local logs be saved to
37-
* `binaryPath`: Optional path to Local binary
37+
* `binarypath`: Optional path to Local binary
3838

3939

4040
## Build

lib/browserstack/local.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@ module BrowserStack
66
class Local
77
attr_reader :pid
88

9-
def initialize(key = nil, binary_path = nil)
9+
def initialize(key = nil)
1010
@key = key
11-
@binary_path = if binary_path.nil?
12-
BrowserStack::LocalBinary.new.binary_path
13-
else
14-
binary_path
15-
end
1611
@logfile = File.join(Dir.pwd, "local.log")
1712
end
1813

@@ -46,6 +41,8 @@ def add_args(key, value=nil)
4641
@hosts = value
4742
elsif key == "logfile"
4843
@logfile = value
44+
elsif key == "binarypath"
45+
@binary_path = value
4946
end
5047
end
5148

@@ -54,6 +51,12 @@ def start(options = {})
5451
self.add_args(key, value)
5552
end
5653

54+
@binary_path = if @binary_path.nil?
55+
BrowserStack::LocalBinary.new.binary_path
56+
else
57+
@binary_path
58+
end
59+
5760
system("echo '' > '#{@logfile}'")
5861
@process = IO.popen(command, "w+")
5962
@stdout = File.open(@logfile, "r")
@@ -85,7 +88,7 @@ def start(options = {})
8588
end
8689

8790
def isRunning
88-
return true if (!@pid.nil? && Process::kill(0, @pid)) rescue false
91+
return true if (!@pid.nil? && Process.kill(0, @pid)) rescue false
8992
end
9093

9194
def stop

lib/browserstack/localbinary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_available_dirs
7777

7878
def make_path(path)
7979
begin
80-
FileUtils.mkdir_p path if !Dir.exists?(path)
80+
FileUtils.mkdir_p path if !File.directory?(path)
8181
return true
8282
rescue Exception => e
8383
puts "Exception #{e.message} #{e.backtrace}"

test/browserstack-local-test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44

55
class BrowserStackLocalTest < Minitest::Test
66
def setup
7-
@bs_local = BrowserStack::Local.new(ENV["BROWSERSTACK_ACCESS_KEY"])
7+
@bs_local = BrowserStack::Local.new
88
end
99

1010
def test_check_pid
11-
@bs_local.start
11+
@bs_local.start({'key' => ENV["BROWSERSTACK_ACCESS_KEY"]})
1212
refute_nil @bs_local.pid, 0
1313
end
1414

1515
def test_is_running
16-
@bs_local.start
16+
@bs_local.start({'key' => ENV["BROWSERSTACK_ACCESS_KEY"]})
1717
assert_equal true, @bs_local.isRunning
1818
end
1919

2020
def test_multiple_binary
21-
@bs_local.start
22-
bs_local_2 = BrowserStack::Local.new(ENV["BROWSERSTACK_ACCESS_KEY"])
21+
@bs_local.start({'key' => ENV["BROWSERSTACK_ACCESS_KEY"]})
22+
bs_local_2 = BrowserStack::Local.new
2323
assert_raises BrowserStack::LocalException do
24-
bs_local_2.start
24+
bs_local_2.start({'key' => ENV["BROWSERSTACK_ACCESS_KEY"]})
2525
end
2626
end
2727

0 commit comments

Comments
 (0)