Class: RSpec::Ui::NgrokHook
- Inherits:
-
Object
- Object
- RSpec::Ui::NgrokHook
- Defined in:
- lib/rspec/ui/ngrok_hook.rb
Constant Summary collapse
- ConfigFile =
File.(File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'ngrok-config-testing'))
- @@current_port =
nil
Class Method Summary collapse
Class Method Details
.shutdown ⇒ Object
31 32 33 |
# File 'lib/rspec/ui/ngrok_hook.rb', line 31 def self.shutdown # TODO end |
.update_browser_army(subdomain) ⇒ Object
35 36 37 |
# File 'lib/rspec/ui/ngrok_hook.rb', line 35 def self.update_browser_army(subdomain) HTTParty.patch("https://#{UxSpec.configuration.uxspec_uri}/#{UxSpec.configuration.token}.json", body: { project: { ngrok_id: subdomain, ngrok_port: @@current_port }}).body end |
.update_port(port) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec/ui/ngrok_hook.rb', line 12 def self.update_port(port) return if @@current_port == port shutdown tunnel = Locoyo::Tunnel.new( port: port, address: '127.0.0.1', protocol: 'http' ) tunnel.run sleep(3) subdomain = tunnel.get_subdomain update_browser_army(subdomain) puts "View on http://uxspec.com/#{UxSpec.configuration.token}" @@current_port = port end |