|
| 1 | +require 'rubygems' |
| 2 | +require 'minitest/autorun' |
| 3 | +require 'browserstack/local' |
| 4 | + |
| 5 | +class BrowserStackLocalTest < Minitest::Test |
| 6 | + def setup |
| 7 | + @bs_local = BrowserStack::Local.new(ENV["BROWSERSTACK_ACCESS_KEY"]) |
| 8 | + end |
| 9 | + |
| 10 | + def test_check_pid |
| 11 | + @bs_local.start |
| 12 | + refute_nil @bs_local.pid, 0 |
| 13 | + end |
| 14 | + |
| 15 | + def test_is_running |
| 16 | + @bs_local.start |
| 17 | + assert_equal true, @bs_local.isRunning |
| 18 | + end |
| 19 | + |
| 20 | + def test_multiple_binary |
| 21 | + @bs_local.start |
| 22 | + bs_local_2 = BrowserStack::Local.new(ENV["BROWSERSTACK_ACCESS_KEY"]) |
| 23 | + assert_raises BrowserStack::LocalException do |
| 24 | + bs_local_2.start |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + def test_enable_verbose |
| 29 | + @bs_local.add_args('v') |
| 30 | + assert_match /\-v/, @bs_local.command |
| 31 | + end |
| 32 | + |
| 33 | + def test_set_folder |
| 34 | + @bs_local.add_args 'f', "/" |
| 35 | + assert_match /\-f/, @bs_local.command |
| 36 | + assert_match /\'\/\'/, @bs_local.command |
| 37 | + end |
| 38 | + |
| 39 | + def test_enable_force |
| 40 | + @bs_local.add_args "force" |
| 41 | + assert_match /\-force/, @bs_local.command |
| 42 | + end |
| 43 | + |
| 44 | + def test_enable_only |
| 45 | + @bs_local.add_args "only" |
| 46 | + assert_match /\-only/, @bs_local.command |
| 47 | + end |
| 48 | + |
| 49 | + def test_enable_only_automate |
| 50 | + @bs_local.add_args "onlyAutomate" |
| 51 | + assert_match /\-onlyAutomate/, @bs_local.command |
| 52 | + end |
| 53 | + |
| 54 | + def test_enable_force_local |
| 55 | + @bs_local.add_args "forcelocal" |
| 56 | + assert_match /\-forcelocal/, @bs_local.command |
| 57 | + end |
| 58 | + |
| 59 | + def test_set_local_identifier |
| 60 | + @bs_local.add_args "localIdentifier", "randomString" |
| 61 | + assert_match /\-localIdentifier \'randomString\'/, @bs_local.command |
| 62 | + end |
| 63 | + |
| 64 | + def test_set_proxy |
| 65 | + @bs_local.add_args "proxyHost", "localhost" |
| 66 | + @bs_local.add_args "proxyPort", 8080 |
| 67 | + @bs_local.add_args "proxyUser", "user" |
| 68 | + @bs_local.add_args "proxyPass", "pass" |
| 69 | + assert_match /\-proxyHost \'localhost\' \-proxyPort 8080 \-proxyUser \'user\' \-proxyPass \'pass\'/, @bs_local.command |
| 70 | + end |
| 71 | + |
| 72 | + def test_hosts |
| 73 | + @bs_local.add_args "hosts", "localhost,8080,0" |
| 74 | + assert_match /localhost\,8080\,0/, @bs_local.command |
| 75 | + end |
| 76 | + |
| 77 | + def teardown |
| 78 | + @bs_local.stop |
| 79 | + end |
| 80 | +end |
0 commit comments