ngrok-wrapper 0.2.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: 73d4023376c99fae6a7c7c0e5461e1fb2fe91d83531bc77e35252e42e87a9795
4
- data.tar.gz: 61eecae9040ebbe584b02cacea0c0a41a84d928dd6ebe7964c20f4b391e155e4
3
+ metadata.gz: 87e9c41fe2c57a9412ff8d75fb5950cc24623778c3b1d5e9a3969fe4c07899e4
4
+ data.tar.gz: cddba38da8b0e540b52534fbd591233a5941b2dcdaf130075215f29a4eb87437
5
5
  SHA512:
6
- metadata.gz: e20e1589b5b0e375acbbd59b0c6e7b472906a1f54534e6695492926fdad36b1aeec2a25fef568fb7527d9416c7a4cae78296473733ccb4166b8c6bbaec95ead4
7
- data.tar.gz: 237102d6642b6f58f5be5e9b35dfe9782863f93662df84c6a9864728df9103c67e4bf12badc87fa481e80b7156b636caab7ecd7058dfb44467e4420968dc191d
6
+ metadata.gz: 1195f3f59babf99244efbb65ba5c1a2ff6e39cd990dcf5472db1bd8eadd1b326161a93a1dafc0fed02e0d544400902ed01ace3bf52bcbedd2bcf4eae1a6eab6a
7
+ data.tar.gz: 66f62592b48a9537d6eeea87661c5a93b076ab03ed4097e726deb3cfa7245e9ef25382e241dccab50e00c31000c3d391da05b7858364440f99437f4a0a7a4ed4
@@ -13,19 +13,16 @@ jobs:
13
13
  fail-fast: false
14
14
  matrix:
15
15
  include:
16
- - ruby: 2.6
17
-
18
- - ruby: 2.7
19
-
20
- - ruby: 3.0
21
-
22
16
  - ruby: 3.1
17
+ - ruby: 3.2
18
+ - ruby: 3.3
19
+ - ruby: head
23
20
 
24
21
  name: ruby ${{ matrix.ruby }}
25
22
 
26
23
  steps:
27
24
  - name: Checkout
28
- uses: actions/checkout@v2
25
+ uses: actions/checkout@v4
29
26
 
30
27
  - name: Set up Ruby
31
28
  uses: ruby/setup-ruby@v1
@@ -40,6 +37,6 @@ jobs:
40
37
  run: bundle exec rspec
41
38
 
42
39
  - name: Code Climate
43
- uses: paambaati/codeclimate-action@v3.0.0
40
+ uses: paambaati/codeclimate-action@v9
44
41
  env:
45
42
  CC_TEST_REPORTER_ID: d1116c05a48e27785cb11369bde3a5e7f9d9e5a114d294bcbefa19cd193b029c
@@ -38,7 +38,7 @@ jobs:
38
38
 
39
39
  steps:
40
40
  - name: Checkout repository
41
- uses: actions/checkout@v2
41
+ uses: actions/checkout@v4
42
42
 
43
43
  # Initializes the CodeQL tools for scanning.
44
44
  - name: Initialize CodeQL
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  .rspec_status
13
13
 
14
14
  test.log
15
+ .idea
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require:
5
5
  - rubocop-performance
6
+ - rubocop-rake
6
7
  - rubocop-rspec
7
8
 
8
9
  inherit_from:
@@ -24,7 +25,7 @@ AllCops:
24
25
  # Additional cops that do not reference a style guide rule may be enabled by
25
26
  # default. Change behavior by overriding StyleGuideCopsOnly, or by giving
26
27
  # the --only-guide-cops option.
27
- TargetRubyVersion: 2.6
28
+ TargetRubyVersion: 3.1
28
29
 
29
30
  Layout/LineLength:
30
31
  Max: 120
@@ -65,8 +66,14 @@ Metrics/BlockLength:
65
66
  RSpec/MultipleExpectations:
66
67
  Max: 13
67
68
 
68
- RSpec/NestedGroups:
69
+ RSpec/MultipleMemoizedHelpers:
70
+ Description: Checks if example groups contain too many `let` and `subject` calls.
71
+ Enabled: true
72
+ AllowSubject: true
69
73
  Max: 7
70
74
 
75
+ RSpec/NestedGroups:
76
+ Max: 8
77
+
71
78
  Style/StringLiterals:
72
79
  ConsistentQuotesInMultiline: true
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.6.9
1
+ ruby 3.3.4
data/CHANGELOG.md CHANGED
@@ -1,7 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.3.1](https://github.com/texpert/ngrok-wrapper/tree/v0.3.1) (2024-08-25)
4
+
5
+ [Full Changelog](https://github.com/texpert/ngrok-wrapper/compare/v0.3.0...v0.3.1)
6
+
7
+ ### Maintenance release
8
+
9
+ Ruby, Rubocop, and CI upgrades
10
+
11
+ **Closed issues:**
12
+
13
+ - Config error with Ngrok v3.3.3 [\#31](https://github.com/texpert/ngrok-wrapper/issues/31)
14
+ - The ngrok agent \(v3\) only accepts long name flags prefixed with -- and will error if a single hyphen is used [\#20](https://github.com/texpert/ngrok-wrapper/issues/20)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Upgrade paambaati/codeclimate-action to version 9 [\#34](https://github.com/texpert/ngrok-wrapper/pull/34) ([texpert](https://github.com/texpert))
19
+ - Upgrade actions/checkout to version 4 [\#33](https://github.com/texpert/ngrok-wrapper/pull/33) ([texpert](https://github.com/texpert))
20
+ - Restrict Ruby minimal version to 3.1 [\#32](https://github.com/texpert/ngrok-wrapper/pull/32) ([texpert](https://github.com/texpert))
21
+ - Bump actions/checkout to 3.5.0 [\#30](https://github.com/texpert/ngrok-wrapper/pull/30) ([texpert](https://github.com/texpert))
22
+ - Bump actions/checkout to 3.3.0 [\#29](https://github.com/texpert/ngrok-wrapper/pull/29) ([texpert](https://github.com/texpert))
23
+ - Bump main Ruby version to 2.7.7 [\#28](https://github.com/texpert/ngrok-wrapper/pull/28) ([texpert](https://github.com/texpert))
24
+ - Fix Code Climate issues [\#27](https://github.com/texpert/ngrok-wrapper/pull/27) ([texpert](https://github.com/texpert))
25
+
26
+ ## [v0.3.0](https://github.com/texpert/ngrok-wrapper/tree/v0.3.0) (2022-11-19)
27
+
28
+ [Full Changelog](https://github.com/texpert/ngrok-wrapper/compare/v0.2.0...v0.3.0)
29
+
30
+ ### Both Ngrok v2, and v3 are now supported.
31
+
32
+ Tested and working on Ubuntu Linux and macOS.
33
+
34
+ **Merged pull requests:**
35
+
36
+ - Added compatibility with Ngrok v3.x \(specs also enhanced to test both 2 and 3 versions\) [\#24](https://github.com/texpert/ngrok-wrapper/pull/24) ([texpert](https://github.com/texpert))
37
+ - Prepare for different ngrok versions params, still for version 2 [\#23](https://github.com/texpert/ngrok-wrapper/pull/23) ([texpert](https://github.com/texpert))
38
+ - Allow region subdomains - modify Rails config.hosts example to parse the host from NGROK\_URL [\#22](https://github.com/texpert/ngrok-wrapper/pull/22) ([texpert](https://github.com/texpert))
39
+ - Set main Ruby version to 2.7.6 [\#21](https://github.com/texpert/ngrok-wrapper/pull/21) ([texpert](https://github.com/texpert))
40
+ - Bump actions/checkout from 2 to 3 [\#19](https://github.com/texpert/ngrok-wrapper/pull/19) ([texpert](https://github.com/texpert))
41
+
3
42
  ## [v0.2.0](https://github.com/texpert/ngrok-wrapper/tree/v0.2.0) (2022-02-19)
4
43
 
44
+ [Full Changelog](https://github.com/texpert/ngrok-wrapper/compare/v0.1.0...v0.2.0)
45
+
5
46
  ### Making Ngrok process survive server stop on Linux
6
47
 
7
48
  It was working OK on Mac OS on the 0.1.0 release, but not on Linux.
@@ -10,7 +51,6 @@ It came out that `Process.setsid` should be applied to the spawned process to es
10
51
  and process group leader. This is completely detaching it from the parent process, so it won't be killed when the
11
52
  parent will go down.
12
53
 
13
- [Full Changelog](https://github.com/texpert/ngrok-wrapper/compare/v0.1.0...v0.2.0)
14
54
 
15
55
  **Merged pull requests:**
16
56
 
data/Gemfile CHANGED
@@ -5,4 +5,11 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in ngrok-wrapper.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'github_changelog_generator', git: 'https://github.com/github-changelog-generator/github-changelog-generator'
9
+ gem 'rake'
10
+ gem 'rspec'
11
+ gem 'rubocop'
12
+ gem 'rubocop-performance'
13
+ gem 'rubocop-rake'
14
+ gem 'rubocop-rspec'
8
15
  gem 'simplecov', require: false, group: :test
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ngrok::Wrapper
2
2
 
3
- Ngrok-wrapper gem is a ruby wrapper for ngrok v2.
3
+ Ngrok-wrapper gem is a ruby wrapper for ngrok v2.x or v3.x.
4
4
 
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/d978e217a8219326e325/maintainability)](https://codeclimate.com/github/texpert/ngrok-wrapper/maintainability)
6
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/d978e217a8219326e325/test_coverage)](https://codeclimate.com/github/texpert/ngrok-wrapper/test_coverage)
@@ -22,7 +22,9 @@ So, excuse me, [Anton Bogdanovich](https://github.com/bogdanovich), but I've dec
22
22
 
23
23
  ## Installation
24
24
 
25
- *Note:* You must have ngrok v2+ installed available in your `PATH`.
25
+ **Pre-requisites:** You must have `ngrok` v2+ or v3+ installed available in your `PATH`.
26
+
27
+ **Upgrade Note:** Do not forget to run `ngrok config upgrade` after upgrading `ngrok` from v2.x to v3.x
26
28
 
27
29
  Add this line to your application's Gemfile:
28
30
 
@@ -32,7 +34,7 @@ gem 'ngrok-wrapper'
32
34
 
33
35
  And then execute:
34
36
 
35
- $ bundle
37
+ $ bundle install
36
38
 
37
39
  Or install it yourself as:
38
40
 
@@ -48,32 +50,32 @@ Ngrok::Wrapper.start
48
50
 
49
51
  # ngrok local_port
50
52
  Ngrok::Wrapper.port
51
- => 3001
53
+ # => 3001
52
54
 
53
55
  # ngrok external url
54
56
  Ngrok::Wrapper.ngrok_url
55
- => "http://aaa0e65.ngrok.io"
57
+ # => "http://aaa0e65.ngrok.io"
56
58
 
57
59
  Ngrok::Wrapper.ngrok_url_https
58
- => "https://aaa0e65.ngrok.io"
60
+ # => "https://aaa0e65.ngrok.io"
59
61
 
60
62
  Ngrok::Wrapper.running?
61
- => true
63
+ # => true
62
64
 
63
65
  Ngrok::Wrapper.stopped?
64
- => false
66
+ # => false
65
67
 
66
68
  # ngrok process id
67
69
  Ngrok::Wrapper.pid
68
- => 27384
70
+ # => 27384
69
71
 
70
72
  # ngrok log file descriptor
71
73
  Ngrok::Wrapper.log
72
- => #<File:/tmp/ngrok20141022-27376-cmmiq4>
74
+ # => #<File:/tmp/ngrok20141022-27376-cmmiq4>
73
75
 
74
76
  # kill ngrok
75
77
  Ngrok::Wrapper.stop
76
- => :stopped
78
+ # => :stopped
77
79
 
78
80
  ```
79
81
 
@@ -139,8 +141,10 @@ end
139
141
  - And in `config/environments/development.rb`:
140
142
 
141
143
  ```ruby
142
- config.force_ssl = true if NGROK_ENABLED
143
- config.hosts << '.ngrok.io' if NGROK_ENABLED # for Rails >= 6.0.0
144
+ if NGROK_ENABLED
145
+ config.force_ssl = true
146
+ config.hosts << URI.parse(NGROK_URL).host # for Rails >= 6.0.0
147
+ end
144
148
 
145
149
  config.action_mailer.default_url_options = {
146
150
  host: NGROK_ENABLED ? NGROK_URL.delete_prefix('https://') : 'myapp.local',
@@ -196,6 +200,7 @@ git pull
196
200
 
197
201
  github_changelog_generator -u texpert -p ngrok-wrapper --future-release v0.1.0
198
202
  ```
203
+ Adjust the new gem version number in the `lib/ngrok/wrapper/version.rb` file.
199
204
 
200
205
  Then add the changes to `git`, commit and push the `Preparing the new release` commit directly into the `main` branch:
201
206
 
@@ -217,7 +222,8 @@ gem owner ngrok-wrapper -a branzeanu.aurel@gmail.com
217
222
 
218
223
  ### Building a new gem version
219
224
 
220
- Adjust the new gem version number in the `lib/ngrok/wrapper/version.rb` file. It is used when building the gem by the following command:
225
+ Check if the new gem version number in the `lib/ngrok/wrapper/version.rb` file has been specified.
226
+ It is used when building the gem by the following command:
221
227
 
222
228
  ```
223
229
  gem build ngrok-wrapper.gemspec
data/disabled.yml CHANGED
@@ -15,6 +15,9 @@ RSpec/BeEql:
15
15
  RSpec/ExampleLength:
16
16
  Enabled: false
17
17
 
18
+ RSpec/PredicateMatcher:
19
+ Enabled: false
20
+
18
21
  RSpec/ExpectInHook:
19
22
  Enabled: false
20
23
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ngrok
4
4
  class Wrapper
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
data/lib/ngrok/wrapper.rb CHANGED
@@ -4,7 +4,16 @@ require_relative 'wrapper/version'
4
4
  require 'tempfile'
5
5
 
6
6
  module Ngrok
7
- OPTIONAL_PARAMS = %i[authtoken bind_tls host_header hostname inspect region subdomain].freeze
7
+ VERSION_PARAMS = {
8
+ '2' => {
9
+ flag_prefix: '-',
10
+ http_tunnel_flags: %i[config authtoken bind_tls host_header hostname inspect region subdomain].freeze
11
+ },
12
+ '3' => {
13
+ flag_prefix: '--',
14
+ http_tunnel_flags: %i[config authtoken scheme host_header hostname inspect region subdomain].freeze
15
+ }
16
+ }.freeze
8
17
 
9
18
  class NotFound < StandardError; end
10
19
  class FetchUrlError < StandardError; end
@@ -24,13 +33,16 @@ module Ngrok
24
33
 
25
34
  def start(params = {})
26
35
  ensure_binary
36
+ @current_version_params = VERSION_PARAMS[@major_version]
37
+ @flag_prefix = @current_version_params[:flag_prefix]
38
+
27
39
  init(params)
28
40
 
29
41
  persistent_ngrok = @params[:persistence] == true
30
42
  # Attempt to read the attributes of an existing process instead of starting a new process.
31
43
  try_params_from_running_ngrok if persistent_ngrok
32
44
 
33
- spawn_new_ngrok(persistent_ngrok: persistent_ngrok) if stopped?
45
+ spawn_new_ngrok(persistent_ngrok:) if stopped?
34
46
 
35
47
  @status = :running
36
48
  if persistent_ngrok
@@ -84,7 +96,7 @@ module Ngrok
84
96
  def raise_if_similar_ngroks(pid)
85
97
  other_ngrok_on_port = ngrok_process_status_lines.find do |line|
86
98
  # If found an Ngrok process with other pid, tunneling on the port, specified in Ngrok::Wrapper.start params
87
- line.include?('ngrok http -log') && !line.start_with?(pid || '') && line.end_with?(addr.to_s)
99
+ line.include?("ngrok http #{@flag_prefix}log") && !line.start_with?(pid || '') && line.end_with?(addr.to_s)
88
100
  end
89
101
 
90
102
  raise Ngrok::Error, "ERROR: Other ngrok instances tunneling to port #{addr} found" if other_ngrok_on_port
@@ -93,7 +105,7 @@ module Ngrok
93
105
 
94
106
  tunnel_on_other_port = ngrok_process_status_lines.find do |line|
95
107
  # If the line starts with this pid, but the port is other than specified in Ngrok::Wrapper.start params
96
- line.include?('ngrok http -log') && line.start_with?(pid) && !line.end_with?(addr.to_s)
108
+ line.include?("ngrok http #{@flag_prefix}log") && line.start_with?(pid) && !line.end_with?(addr.to_s)
97
109
  end
98
110
 
99
111
  return unless tunnel_on_other_port
@@ -104,7 +116,7 @@ module Ngrok
104
116
  def ngrok_process_status_lines(refetch: false)
105
117
  return @ngrok_process_status_lines if defined?(@ngrok_process_status_lines) && !refetch
106
118
 
107
- @ngrok_process_status_lines = (`ps ax | grep "ngrok http"`).split("\n").map(&:strip)
119
+ @ngrok_process_status_lines = `ps ax | grep "ngrok http"`.split("\n").map(&:strip)
108
120
  end
109
121
 
110
122
  def try_params_from_running_ngrok
@@ -125,7 +137,7 @@ module Ngrok
125
137
  def ngrok_running?(pid)
126
138
  ngrok_process_status_lines.find do |line|
127
139
  # If found the Ngrok process with correct pid, tunneling on the port, specified in Ngrok::Wrapper.start params
128
- line.include?('ngrok http -log') && line.start_with?(pid) && line.end_with?(addr.to_s)
140
+ line.include?("ngrok http #{@flag_prefix}log") && line.start_with?(pid) && line.end_with?(addr.to_s)
129
141
  end
130
142
  end
131
143
 
@@ -142,7 +154,7 @@ module Ngrok
142
154
  sleep 0.5
143
155
 
144
156
  @pid = ngrok_process_status_lines(refetch: true)
145
- .find { |line| line.include?('ngrok http -log') && line.end_with?(addr.to_s) }.split[0]
157
+ .find { |line| line.include?("ngrok http #{@flag_prefix}log") && line.end_with?(addr.to_s) }.split[0]
146
158
  else
147
159
  @pid = Process.spawn("exec ngrok http #{ngrok_exec_params}")
148
160
  at_exit { Ngrok::Wrapper.stop }
@@ -152,11 +164,11 @@ module Ngrok
152
164
  end
153
165
 
154
166
  def ngrok_exec_params
155
- exec_params = +'-log=stdout -log-level=debug '
156
- OPTIONAL_PARAMS.each do |opt|
157
- exec_params << "-#{opt.to_s.tr('_', '-')}=#{@params[opt]} " if @params.key?(opt)
167
+ exec_params = +"#{@flag_prefix}log=stdout #{@flag_prefix}log-level=debug "
168
+ @current_version_params[:http_tunnel_flags].each do |flag|
169
+ exec_params << "#{@flag_prefix}#{flag.to_s.tr('_', '-')}=#{@params[flag]} " if @params.key?(flag)
158
170
  end
159
- exec_params << "-config #{@params[:config]} #{@params[:addr]} > #{@params[:log].path}"
171
+ exec_params << " #{@params[:addr]} > #{@params[:log].path}"
160
172
  end
161
173
 
162
174
  def fetch_urls
@@ -191,7 +203,7 @@ module Ngrok
191
203
  end
192
204
 
193
205
  def ensure_binary
194
- `ngrok version`
206
+ @major_version, * = `ngrok version`.chomp.delete_prefix('ngrok version ').split('.')
195
207
  rescue Errno::ENOENT
196
208
  raise Ngrok::NotFound, 'Ngrok binary not found'
197
209
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.summary = 'Ngrok-wrapper gem is a ruby wrapper for ngrok2'
15
15
  spec.description = 'Ngrok-wrapper gem is a ruby wrapper for ngrok2'
16
16
  spec.homepage = 'https://github.com/texpert/ngrok-wrapper'
17
- spec.required_ruby_version = '>= 2.6.0'
17
+ spec.required_ruby_version = '>= 3.1.0'
18
18
  spec.license = 'MIT'
19
19
 
20
20
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -25,13 +25,5 @@ Gem::Specification.new do |spec|
25
25
  # Specify which files should be added to the gem when it is released.
26
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
27
  spec.files = `git ls-files -z`.split("\x0")
28
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
29
28
  spec.require_paths = ['lib']
30
-
31
- spec.add_development_dependency 'github_changelog_generator'
32
- spec.add_development_dependency 'rake'
33
- spec.add_development_dependency 'rspec'
34
- spec.add_development_dependency 'rubocop'
35
- spec.add_development_dependency 'rubocop-performance'
36
- spec.add_development_dependency 'rubocop-rspec'
37
29
  end
@@ -4,354 +4,369 @@ RSpec.describe 'Ngrok::Wrapper' do
4
4
  let(:log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.sample.log") }
5
5
  let(:fake_pid) { rand(99_999) }
6
6
 
7
- before do
8
- allow(Ngrok::Wrapper).to receive(:ensure_binary)
9
- allow(Ngrok::Wrapper).to receive(:raise_if_similar_ngroks)
10
- allow(Process).to receive(:spawn).and_return(fake_pid)
11
- allow(Process).to receive(:kill)
12
- end
13
-
14
- it 'has a version number' do
15
- expect(Ngrok::Wrapper::VERSION).not_to be nil
16
- end
17
-
18
- describe 'Before start' do
19
- before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
7
+ ngrok_versions = %w[2 3]
20
8
 
21
- it 'is not running' do
22
- expect(Ngrok::Wrapper.running?).to be false
23
- end
24
-
25
- it 'is stopped' do
26
- expect(Ngrok::Wrapper.stopped?).to be true
27
- end
9
+ ngrok_versions.each do |ngrok_version|
10
+ describe "Ngrok v#{ngrok_version}" do
11
+ let(:flag_prefix) { Ngrok::VERSION_PARAMS[ngrok_version][:flag_prefix] }
12
+ let(:config_path) { "#{flag_prefix}config /Users/thunder/.ngrok2/ngrok.yml" }
28
13
 
29
- it 'has :stopped status' do
30
- expect(Ngrok::Wrapper.status).to eq :stopped
31
- end
32
- end
14
+ before do
15
+ Ngrok::Wrapper.instance_variable_set(:@major_version, ngrok_version)
16
+ allow(Ngrok::Wrapper).to receive(:ensure_binary)
17
+ allow(Ngrok::Wrapper).to receive(:ngrok_process_status_lines)
18
+ allow(Ngrok::Wrapper).to receive(:raise_if_similar_ngroks)
19
+ allow(Process).to receive(:spawn).and_return(fake_pid)
20
+ allow(Process).to receive(:kill)
21
+ end
33
22
 
34
- describe 'After start' do
35
- before do
36
- allow_any_instance_of(Tempfile).to receive(:read).and_return(log)
23
+ it 'has a version number' do
24
+ expect(Ngrok::Wrapper::VERSION).not_to be_nil
25
+ end
37
26
 
38
- Ngrok::Wrapper.start
39
- end
27
+ describe 'Before start' do
28
+ before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
40
29
 
41
- after { Ngrok::Wrapper.stop }
30
+ it 'is not running' do
31
+ expect(Ngrok::Wrapper.running?).to be false
32
+ end
42
33
 
43
- it 'is running' do
44
- expect(Ngrok::Wrapper.running?).to be true
45
- end
34
+ it 'is stopped' do
35
+ expect(Ngrok::Wrapper.stopped?).to be true
36
+ end
46
37
 
47
- it 'is not stopped' do
48
- expect(Ngrok::Wrapper.stopped?).to be false
49
- end
38
+ it 'has :stopped status' do
39
+ expect(Ngrok::Wrapper.status).to eq :stopped
40
+ end
41
+ end
50
42
 
51
- it 'has :running status' do
52
- expect(Ngrok::Wrapper.status).to eq :running
53
- end
43
+ describe 'After start' do
44
+ before do
45
+ allow_any_instance_of(Tempfile).to receive(:read).and_return(log)
54
46
 
55
- it 'has correct port property' do
56
- expect(Ngrok::Wrapper.port).to eq(3001)
57
- end
47
+ Ngrok::Wrapper.start
48
+ end
58
49
 
59
- it 'has correct addr property' do
60
- expect(Ngrok::Wrapper.addr).to eq(3001)
61
- end
50
+ after { Ngrok::Wrapper.stop }
62
51
 
63
- it 'has valid ngrok_url' do
64
- expect(Ngrok::Wrapper.ngrok_url).to be =~ %r{http://.*ngrok\.io$}
65
- end
52
+ it 'is running' do
53
+ expect(Ngrok::Wrapper.running?).to be true
54
+ end
66
55
 
67
- it 'has valid ngrok_url_https' do
68
- expect(Ngrok::Wrapper.ngrok_url_https).to be =~ %r{https://.*ngrok\.io$}
69
- end
56
+ it 'is not stopped' do
57
+ expect(Ngrok::Wrapper.stopped?).to be false
58
+ end
70
59
 
71
- it 'has correct pid property' do
72
- expect(Ngrok::Wrapper.pid).to be > 0
73
- end
74
- end
60
+ it 'has :running status' do
61
+ expect(Ngrok::Wrapper.status).to eq :running
62
+ end
75
63
 
76
- describe 'Custom log file' do
77
- before { allow_any_instance_of(File).to receive(:read).and_return(log) }
64
+ it 'has correct port property' do
65
+ expect(Ngrok::Wrapper.port).to eq(3001)
66
+ end
78
67
 
79
- it 'uses custom log file' do
80
- Ngrok::Wrapper.start(log: 'test.log')
81
- expect(Ngrok::Wrapper.running?).to eq true
82
- expect(Ngrok::Wrapper.params[:log].path).to eq 'test.log'
83
- Ngrok::Wrapper.stop
84
- expect(Ngrok::Wrapper.stopped?).to eq true
85
- end
86
- end
68
+ it 'has correct addr property' do
69
+ expect(Ngrok::Wrapper.addr).to eq(3001)
70
+ end
87
71
 
88
- describe 'Invalid or missing authtoken' do
89
- describe 'when no authtoken is specified in ngrok config file' do
90
- let(:no_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }
72
+ it 'has valid ngrok_url' do
73
+ expect(Ngrok::Wrapper.ngrok_url).to be =~ %r{http://.*ngrok\.io$}
74
+ end
91
75
 
92
- it 'raises Ngrok::Error exception' do
93
- allow_any_instance_of(Tempfile).to receive(:read).and_return(no_auth_log)
76
+ it 'has valid ngrok_url_https' do
77
+ expect(Ngrok::Wrapper.ngrok_url_https).to be =~ %r{https://.*ngrok\.io$}
78
+ end
94
79
 
95
- expect { Ngrok::Wrapper.start }.to raise_error Ngrok::Error
80
+ it 'has correct pid property' do
81
+ expect(Ngrok::Wrapper.pid).to be > 0
82
+ end
96
83
  end
97
- end
98
-
99
- describe 'when an invalid authtoken is specified in ngrok config file' do
100
- let(:invalid_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }
101
84
 
102
- it 'fails with incorrect authtoken' do
103
- allow_any_instance_of(Tempfile).to receive(:read).and_return(invalid_auth_log)
85
+ describe 'Custom log file' do
86
+ before { allow_any_instance_of(File).to receive(:read).and_return(log) }
104
87
 
105
- expect do
106
- Ngrok::Wrapper.start(authtoken: 'incorrect_token')
107
- end.to raise_error Ngrok::Error
88
+ it 'uses custom log file' do
89
+ Ngrok::Wrapper.start(log: 'test.log')
90
+ expect(Ngrok::Wrapper.running?).to be_truthy
91
+ expect(Ngrok::Wrapper.params[:log].path).to eq 'test.log'
92
+ Ngrok::Wrapper.stop
93
+ expect(Ngrok::Wrapper.stopped?).to be_truthy
94
+ end
108
95
  end
109
- end
110
- end
111
96
 
112
- describe 'Custom addr' do
113
- before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
97
+ describe 'Invalid or missing authtoken' do
98
+ describe 'when no authtoken is specified in ngrok config file' do
99
+ let(:no_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }
114
100
 
115
- it 'maps port param to addr' do
116
- port = 10_010
117
- Ngrok::Wrapper.start(port: port)
118
- expect(Ngrok::Wrapper.addr).to eq port
119
- Ngrok::Wrapper.stop
120
- end
101
+ it 'raises Ngrok::Error exception' do
102
+ allow_any_instance_of(Tempfile).to receive(:read).and_return(no_auth_log)
121
103
 
122
- it 'returns just the port when the address contains a host' do
123
- addr = '192.168.0.5:10010'
124
- Ngrok::Wrapper.start(addr: addr)
125
- expect(Ngrok::Wrapper.port).to eq 10_010
126
- Ngrok::Wrapper.stop
127
- end
104
+ expect { Ngrok::Wrapper.start }.to raise_error Ngrok::Error
105
+ end
106
+ end
128
107
 
129
- it 'supports remote addresses' do
130
- addr = '192.168.0.5:10010'
131
- Ngrok::Wrapper.start(addr: addr)
132
- expect(Ngrok::Wrapper.addr).to eq addr
133
- Ngrok::Wrapper.stop
134
- end
135
- end
108
+ describe 'when an invalid authtoken is specified in ngrok config file' do
109
+ let(:invalid_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }
136
110
 
137
- describe 'Custom region' do
138
- before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
111
+ it 'fails with incorrect authtoken' do
112
+ allow_any_instance_of(Tempfile).to receive(:read).and_return(invalid_auth_log)
139
113
 
140
- it "doesn't include the -region parameter when it is not provided" do
141
- Ngrok::Wrapper.start
142
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-region=')
143
- Ngrok::Wrapper.stop
144
- end
114
+ expect do
115
+ Ngrok::Wrapper.start(authtoken: 'incorrect_token')
116
+ end.to raise_error Ngrok::Error
117
+ end
118
+ end
119
+ end
145
120
 
146
- it 'includes the -region parameter with the correct value when it is provided' do
147
- region = 'eu'
148
- Ngrok::Wrapper.start(region: region)
149
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include("-region=#{region}")
150
- Ngrok::Wrapper.stop
151
- end
152
- end
121
+ describe 'Custom addr' do
122
+ before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
153
123
 
154
- describe 'Custom bind-tls' do
155
- before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
124
+ after { Ngrok::Wrapper.stop }
156
125
 
157
- it "doesn't include the -bind-tls parameter when it is not provided" do
158
- Ngrok::Wrapper.start
159
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-bind-tls=')
160
- Ngrok::Wrapper.stop
161
- end
126
+ it 'maps port param to addr' do
127
+ port = 10_010
128
+ Ngrok::Wrapper.start(port:)
129
+ expect(Ngrok::Wrapper.addr).to eq port
130
+ end
162
131
 
163
- it 'includes the -bind-tls parameter with the correct value when it is true' do
164
- bind_tls = true
165
- Ngrok::Wrapper.start(bind_tls: bind_tls)
166
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include("-bind-tls=#{bind_tls}")
167
- Ngrok::Wrapper.stop
168
- end
132
+ it 'returns just the port when the address contains a host' do
133
+ addr = '192.168.0.5:10010'
134
+ Ngrok::Wrapper.start(addr:)
135
+ expect(Ngrok::Wrapper.port).to eq 10_010
136
+ end
169
137
 
170
- it 'includes the -bind-tls parameter with the correct value when it is false' do
171
- bind_tls = false
172
- Ngrok::Wrapper.start(bind_tls: bind_tls)
173
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include("-bind-tls=#{bind_tls}")
174
- Ngrok::Wrapper.stop
175
- end
176
- end
138
+ it 'supports remote addresses' do
139
+ addr = '192.168.0.5:10010'
140
+ Ngrok::Wrapper.start(addr:)
141
+ expect(Ngrok::Wrapper.addr).to eq addr
142
+ end
143
+ end
177
144
 
178
- describe 'Custom host header' do
179
- after { Ngrok::Wrapper.stop }
145
+ describe 'Custom region' do
146
+ before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
180
147
 
181
- it "doesn't include the -host-header parameter when it is not provided" do
182
- expect(Ngrok::Wrapper).to receive(:fetch_urls)
183
- Ngrok::Wrapper.start
184
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-host-header=')
185
- end
148
+ after { Ngrok::Wrapper.stop }
186
149
 
187
- it 'includes the -host-header parameter with the correct value when it is provided' do
188
- expect(Ngrok::Wrapper).to receive(:fetch_urls)
189
- host_header = 'foo.bar'
190
- Ngrok::Wrapper.start(host_header: host_header)
191
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include("-host-header=#{host_header}")
192
- end
193
- end
150
+ it "doesn't include the -region parameter when it is not provided" do
151
+ Ngrok::Wrapper.start
152
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-region=')
153
+ end
194
154
 
195
- describe 'Custom parameters provided' do
196
- before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
155
+ it 'includes the -region parameter with the correct value when it is provided' do
156
+ region = 'eu'
157
+ Ngrok::Wrapper.start(region:)
158
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include("-region=#{region}")
159
+ end
160
+ end
197
161
 
198
- it "doesn't include the -inspect parameter when it is not provided" do
199
- Ngrok::Wrapper.start
200
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-inspect=')
201
- Ngrok::Wrapper.stop
202
- end
162
+ describe 'Custom bind-tls' do
163
+ # It is 'bind_tls' for Ngrok v2, and 'scheme' for Ngrok v3
164
+ let(:bind_tls_flag) { Ngrok::VERSION_PARAMS[ngrok_version][:http_tunnel_flags][2] }
203
165
 
204
- it 'includes the -inspect parameter with the correct value when it is provided' do
205
- Ngrok::Wrapper.start(inspect: true)
206
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include('-inspect=true')
207
- Ngrok::Wrapper.stop
166
+ before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
208
167
 
209
- Ngrok::Wrapper.start(inspect: false)
210
- expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include('-inspect=false')
211
- Ngrok::Wrapper.stop
212
- end
213
- end
168
+ after { Ngrok::Wrapper.stop }
214
169
 
215
- describe '#start' do
216
- after { Ngrok::Wrapper.stop }
170
+ it "doesn't include the -bind-tls parameter when it is not provided" do
171
+ Ngrok::Wrapper.start
172
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params))
173
+ .not_to include("#{flag_prefix}#{bind_tls_flag.to_s.tr('_', '-')}=")
174
+ end
217
175
 
218
- describe 'when persistence param is true' do
219
- before do
220
- allow(File).to receive(:write)
221
- allow(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok).and_call_original
222
- allow(Ngrok::Wrapper).to receive(:parse_persistence_file).and_return(state)
223
- end
176
+ it 'includes the -bind-tls parameter with the correct value when it is true' do
177
+ Ngrok::Wrapper.start(bind_tls_flag => true)
178
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params))
179
+ .to include("#{flag_prefix}#{bind_tls_flag.to_s.tr('_', '-')}=true")
180
+ end
224
181
 
225
- describe 'tries fetching params of an already running Ngrok and store Ngrok process data into a file' do
226
- describe 'when fetching params returns nil' do
227
- let(:state) { nil }
182
+ it 'includes the -bind-tls parameter with the correct value when it is false' do
183
+ Ngrok::Wrapper.start(bind_tls_flag => false)
184
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params))
185
+ .to include("#{flag_prefix}#{bind_tls_flag.to_s.tr('_', '-')}=false")
186
+ end
187
+ end
228
188
 
229
- it "doesn't check for similar ngroks running" do
230
- expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
231
- expect(Ngrok::Wrapper).not_to receive(:raise_if_similar_ngroks)
232
- expect(Ngrok::Wrapper).not_to receive(:ngrok_running?)
233
- expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true)
234
- expect(File).to receive(:write)
189
+ describe 'Custom host header' do
190
+ after { Ngrok::Wrapper.stop }
235
191
 
236
- Ngrok::Wrapper.start(persistence: true)
237
- end
192
+ it "doesn't include the -host-header parameter when it is not provided" do
193
+ expect(Ngrok::Wrapper).to receive(:fetch_urls)
194
+ Ngrok::Wrapper.start
195
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-host-header=')
238
196
  end
239
197
 
240
- describe 'when fetching params returns a legit hash' do
241
- let(:state) do
242
- { 'pid' => '795',
243
- 'ngrok_url' => 'http://b1cd-109-185-141-9.ngrok.io',
244
- 'ngrok_url_https' => 'https://b1cd-109-185-141-9.ngrok.io' }
245
- end
198
+ it 'includes the -host-header parameter with the correct value when it is provided' do
199
+ expect(Ngrok::Wrapper).to receive(:fetch_urls)
200
+ host_header = 'foo.bar'
201
+ Ngrok::Wrapper.start(host_header:)
202
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include("-host-header=#{host_header}")
203
+ end
204
+ end
246
205
 
247
- describe 'checking if a similar Ngrok is running' do
248
- before do
249
- allow(Ngrok::Wrapper).to receive(:raise_if_similar_ngroks).and_call_original
250
- allow(Ngrok::Wrapper).to receive(:ngrok_process_status_lines).and_return(ngrok_ps_lines)
206
+ describe 'Custom parameters provided' do
207
+ before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }
251
208
 
252
- expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
253
- end
209
+ it "doesn't include the -inspect parameter when it is not provided" do
210
+ Ngrok::Wrapper.start
211
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).not_to include('-inspect=')
212
+ Ngrok::Wrapper.stop
213
+ end
254
214
 
255
- describe 'when Ngrok process with params from the persisted file is running' do
256
- let(:ngrok_ps_lines) do
257
- ['795 ?? S 0:04.81 ngrok http -log -config /Users/thunder/.ngrok2/ngrok.yml https://localhost:3001']
258
- end
215
+ it 'includes the -inspect parameter with the correct value when it is provided' do
216
+ Ngrok::Wrapper.start(inspect: true)
217
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include('-inspect=true')
218
+ Ngrok::Wrapper.stop
259
219
 
260
- it 'set Ngrok::Wrapper pid and status attributes' do
261
- expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
220
+ Ngrok::Wrapper.start(inspect: false)
221
+ expect(Ngrok::Wrapper.__send__(:ngrok_exec_params)).to include('-inspect=false')
222
+ Ngrok::Wrapper.stop
223
+ end
224
+ end
262
225
 
263
- result = Ngrok::Wrapper.start(persistence: true)
226
+ describe '#start' do
227
+ after { Ngrok::Wrapper.stop }
264
228
 
265
- expect(Ngrok::Wrapper.pid).to eql('795')
266
- expect(Ngrok::Wrapper.status).to eql(:running)
267
- expect(Ngrok::Wrapper.ngrok_url).to eql('http://b1cd-109-185-141-9.ngrok.io')
268
- expect(Ngrok::Wrapper.ngrok_url_https).to eql('https://b1cd-109-185-141-9.ngrok.io')
269
- expect(result).to eql('https://b1cd-109-185-141-9.ngrok.io')
270
- end
271
- end
229
+ describe 'when persistence param is true' do
230
+ before do
231
+ allow(File).to receive(:write)
232
+ allow(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok).and_call_original
233
+ allow(Ngrok::Wrapper).to receive(:parse_persistence_file).and_return(state)
234
+ end
272
235
 
273
- describe 'when a similar Ngrok with other pid is already running' do
274
- let(:ngrok_ps_lines) do
275
- ['71986 ?? S 0:04.81 ngrok http -log -config /Users/thunder/.ngrok2/ngrok.yml https://localhost:3001']
276
- end
236
+ describe 'tries fetching params of an already running Ngrok and store Ngrok process data into a file' do
237
+ describe 'when fetching params returns nil' do
238
+ let(:state) { nil }
277
239
 
278
- it 'raises exception' do
279
- expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
240
+ it "doesn't check for similar ngroks running" do
241
+ expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
242
+ expect(Ngrok::Wrapper).not_to receive(:raise_if_similar_ngroks)
243
+ expect(Ngrok::Wrapper).not_to receive(:ngrok_running?)
244
+ expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true)
245
+ expect(File).to receive(:write)
280
246
 
281
- expect { Ngrok::Wrapper.start(persistence: true) }
282
- .to raise_error(Ngrok::Error, 'ERROR: Other ngrok instances tunneling to port 3001 found')
247
+ Ngrok::Wrapper.start(persistence: true)
283
248
  end
284
249
  end
285
250
 
286
- describe 'when Ngrok with the persisted pid is already running, but on a different port' do
251
+ describe 'when fetching params returns a legit hash' do
287
252
  let(:ngrok_ps_lines) do
288
- ['795 ?? S 0:04.81 ngrok http -log -config /Users/thunder/.ngrok2/ngrok.yml https://localhost:3000']
253
+ ["795 ?? S 0:04.81 ngrok http #{flag_prefix}log -config #{config_path} https://localhost:3001"]
289
254
  end
290
255
 
291
- it 'raises exception' do
292
- expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
293
-
294
- expect { Ngrok::Wrapper.start(persistence: true) }
295
- .to raise_error(Ngrok::Error, 'ERROR: Ngrok pid #795 tunneling on other port 3000')
296
- end
297
- end
298
-
299
- describe 'when no Ngrok process with params from the persisted file or similar is running' do
300
- let(:ngrok_ps_lines) do
301
- ['834 ?? S 0:04.81 ngrok http -log -config /Users/thunder/.ngrok2/ngrok.yml https://localhost:5001']
256
+ let(:state) do
257
+ { 'pid' => '795',
258
+ 'ngrok_url' => 'http://b1cd-109-185-141-9.ngrok.io',
259
+ 'ngrok_url_https' => 'https://b1cd-109-185-141-9.ngrok.io' }
302
260
  end
303
261
 
304
- let(:new_ngrok_ps_lines) do
305
- ['835 ?? S 0:04.81 ngrok http -log -config /Users/thunder/.ngrok2/ngrok.yml https://localhost:3001']
262
+ before { allow(Ngrok::Wrapper).to receive(:ngrok_process_status_lines).and_return(ngrok_ps_lines) }
263
+
264
+ describe 'checking if a similar Ngrok is running' do
265
+ before do
266
+ allow(Ngrok::Wrapper).to receive(:raise_if_similar_ngroks).and_call_original
267
+
268
+ expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
269
+ end
270
+
271
+ describe 'when Ngrok process with params from the persisted file is running' do
272
+ it 'set Ngrok::Wrapper pid and status attributes' do
273
+ expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
274
+
275
+ result = Ngrok::Wrapper.start(persistence: true)
276
+
277
+ expect(Ngrok::Wrapper.pid).to eql('795')
278
+ expect(Ngrok::Wrapper.status).to eql(:running)
279
+ expect(Ngrok::Wrapper.ngrok_url).to eql('http://b1cd-109-185-141-9.ngrok.io')
280
+ expect(Ngrok::Wrapper.ngrok_url_https).to eql('https://b1cd-109-185-141-9.ngrok.io')
281
+ expect(result).to eql('https://b1cd-109-185-141-9.ngrok.io')
282
+ end
283
+ end
284
+
285
+ describe 'when a similar Ngrok with other pid is already running' do
286
+ let(:ngrok_ps_lines) do
287
+ ["71986 ?? S 0:04.81 ngrok http #{flag_prefix}log -config #{config_path} https://localhost:3001"]
288
+ end
289
+
290
+ it 'raises exception' do
291
+ expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
292
+
293
+ expect { Ngrok::Wrapper.start(persistence: true) }
294
+ .to raise_error(Ngrok::Error, 'ERROR: Other ngrok instances tunneling to port 3001 found')
295
+ end
296
+ end
297
+
298
+ describe 'when Ngrok with the persisted pid is already running, but on a different port' do
299
+ let(:ngrok_ps_lines) do
300
+ ["795 ?? S 0:04.81 ngrok http #{flag_prefix}log -config #{config_path} https://localhost:3000"]
301
+ end
302
+
303
+ it 'raises exception' do
304
+ expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
305
+
306
+ expect { Ngrok::Wrapper.start(persistence: true) }
307
+ .to raise_error(Ngrok::Error, 'ERROR: Ngrok pid #795 tunneling on other port 3000')
308
+ end
309
+ end
310
+
311
+ describe 'when no Ngrok process with params from the persisted file or similar is running' do
312
+ let(:ngrok_ps_lines) do
313
+ ["834 ?? S 0:04.81 ngrok http #{flag_prefix}log -config #{config_path} https://localhost:5001"]
314
+ end
315
+
316
+ let(:new_ngrok_ps_lines) do
317
+ ["835 ?? S 0:04.81 ngrok http #{flag_prefix}log -config #{config_path} https://localhost:3001"]
318
+ end
319
+
320
+ it 'sets Ngrok::Wrapper pid and status attributes' do
321
+ allow(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true).and_call_original
322
+ allow(Ngrok::Wrapper).to receive(:fork)
323
+ allow(Ngrok::Wrapper)
324
+ .to receive(:ngrok_process_status_lines).with(refetch: true).and_return(new_ngrok_ps_lines)
325
+ allow(Ngrok::Wrapper).to receive(:fetch_urls)
326
+
327
+ expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true)
328
+ expect(Ngrok::Wrapper).to receive(:fork)
329
+ expect(Ngrok::Wrapper).to receive(:ngrok_process_status_lines).with(refetch: true)
330
+ allow(Ngrok::Wrapper).to receive(:fetch_urls)
331
+
332
+ Ngrok::Wrapper.start(persistence: true)
333
+
334
+ expect(Ngrok::Wrapper.pid).to eql('835')
335
+ expect(Ngrok::Wrapper.status).to eql(:running)
336
+ end
337
+ end
306
338
  end
307
339
 
308
- it 'sets Ngrok::Wrapper pid and status attributes' do
309
- allow(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true).and_call_original
310
- allow(Ngrok::Wrapper).to receive(:fork).and_call_original
311
- allow(Ngrok::Wrapper)
312
- .to receive(:ngrok_process_status_lines).with(refetch: true).and_return(new_ngrok_ps_lines)
313
- allow(Ngrok::Wrapper).to receive(:fetch_urls)
314
-
315
- expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true)
316
- expect(Ngrok::Wrapper).to receive(:fork)
317
- expect(Ngrok::Wrapper).to receive(:ngrok_process_status_lines).with(refetch: true)
318
- allow(Ngrok::Wrapper).to receive(:fetch_urls)
340
+ it 'tries fetching params of an already running Ngrok and store Ngrok process data into a file' do
341
+ expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
342
+ expect(File).to receive(:write)
319
343
 
320
344
  Ngrok::Wrapper.start(persistence: true)
321
-
322
- expect(Ngrok::Wrapper.pid).to eql('835')
323
- expect(Ngrok::Wrapper.status).to eql(:running)
324
345
  end
325
346
  end
326
347
  end
348
+ end
349
+
350
+ describe 'when persistence param is not true' do
351
+ after { Ngrok::Wrapper.stop }
327
352
 
328
- it 'tries fetching params of an already running Ngrok and store Ngrok process data into a file' do
329
- expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
330
- expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true)
331
- expect(File).to receive(:write)
353
+ it "doesn't try to fetch params of an already running Ngrok" do
354
+ expect(Ngrok::Wrapper).not_to receive(:try_params_from_running_ngrok)
355
+ expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: false)
356
+ expect_any_instance_of(File).not_to receive(:write)
332
357
 
333
- Ngrok::Wrapper.start(persistence: true)
358
+ Ngrok::Wrapper.start(persistence: false)
334
359
  end
335
360
  end
336
- end
337
- end
338
-
339
- describe 'when persistence param is not true' do
340
- it "doesn't try to fetch params of an already running Ngrok" do
341
- expect(Ngrok::Wrapper).not_to receive(:try_params_from_running_ngrok)
342
- expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: false)
343
- expect_any_instance_of(File).not_to receive(:write)
344
361
 
345
- Ngrok::Wrapper.start(persistence: false)
346
- end
347
- end
362
+ describe 'when Ngrok::Wrapper is already running' do
363
+ it "doesn't try to spawn a new Ngrok process" do
364
+ allow(Ngrok::Wrapper).to receive(:stopped?).and_return(false)
365
+ expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
348
366
 
349
- describe 'when Ngrok::Wrapper is already running' do
350
- it "doesn't try to spawn a new Ngrok process" do
351
- allow(Ngrok::Wrapper).to receive(:stopped?).and_return(false)
352
- expect(Ngrok::Wrapper).not_to receive(:spawn_new_ngrok)
353
-
354
- Ngrok::Wrapper.start
367
+ Ngrok::Wrapper.start
368
+ end
369
+ end
355
370
  end
356
371
  end
357
372
  end
data/tea.yaml ADDED
@@ -0,0 +1,6 @@
1
+ # https://tea.xyz/what-is-this-file
2
+ ---
3
+ version: 1.0.0
4
+ codeOwners:
5
+ - '0x0bad48252Fa11ec363C21C0a3232F869b13808c0'
6
+ quorum: 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ngrok-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Bogdanovich
@@ -9,92 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-19 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: github_changelog_generator
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: rake
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: rspec
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: rubocop
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: rubocop-performance
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: rubocop-rspec
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
12
+ date: 2024-08-25 00:00:00.000000000 Z
13
+ dependencies: []
98
14
  description: Ngrok-wrapper gem is a ruby wrapper for ngrok2
99
15
  email:
100
16
  - 27bogdanovich@gmail.com
@@ -109,7 +25,6 @@ files:
109
25
  - ".gitignore"
110
26
  - ".rspec"
111
27
  - ".rubocop.yml"
112
- - ".ruby-version"
113
28
  - ".simplecov"
114
29
  - ".tool-versions"
115
30
  - CHANGELOG.md
@@ -128,6 +43,7 @@ files:
128
43
  - spec/fixtures/ngrok_invalid_auth_token.log
129
44
  - spec/ngrok/wrapper_spec.rb
130
45
  - spec/spec_helper.rb
46
+ - tea.yaml
131
47
  homepage: https://github.com/texpert/ngrok-wrapper
132
48
  licenses:
133
49
  - MIT
@@ -144,20 +60,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
60
  requirements:
145
61
  - - ">="
146
62
  - !ruby/object:Gem::Version
147
- version: 2.6.0
63
+ version: 3.1.0
148
64
  required_rubygems_version: !ruby/object:Gem::Requirement
149
65
  requirements:
150
66
  - - ">="
151
67
  - !ruby/object:Gem::Version
152
68
  version: '0'
153
69
  requirements: []
154
- rubygems_version: 3.0.3.1
70
+ rubygems_version: 3.5.11
155
71
  signing_key:
156
72
  specification_version: 4
157
73
  summary: Ngrok-wrapper gem is a ruby wrapper for ngrok2
158
- test_files:
159
- - spec/fixtures/ngrok.no_auth_token.log
160
- - spec/fixtures/ngrok.sample.log
161
- - spec/fixtures/ngrok_invalid_auth_token.log
162
- - spec/ngrok/wrapper_spec.rb
163
- - spec/spec_helper.rb
74
+ test_files: []
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.6.9