Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codeclimate fixme and rubocop plugins #10

Merged
merged 2 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "2"
exclude_patterns:
- "sig/**/*"
checks:
argument-count:
config:
threshold: 4
complex-logic:
config:
threshold: 4
file-lines:
config:
threshold: 300
method-complexity:
config:
threshold: 9
method-count:
config:
threshold: 20
method-lines:
config:
threshold: 25
nested-control-flow:
config:
threshold: 4
return-statements:
config:
threshold: 4
plugins:
rubocop:
enabled: true
channel: 'rubocop-1-24-1'
fixme:
enabled: true
config:
strings:
- FIXME
- BUG
- CUSTOM
35 changes: 7 additions & 28 deletions spec/ngrok/wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@
end
end

describe 'Custom subdomain' do
describe 'Invalid or missing authtoken' do
describe 'when no authtoken is specified in ngrok config file' do
let(:no_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }

it 'raises Ngrok::Error exception' do
allow_any_instance_of(Tempfile).to receive(:read).and_return(no_auth_log)

expect { Ngrok::Wrapper.start(subdomain: 'test-subdomain') }.to raise_error Ngrok::Error
expect { Ngrok::Wrapper.start }.to raise_error Ngrok::Error
end
end

Expand All @@ -103,35 +103,12 @@
allow_any_instance_of(Tempfile).to receive(:read).and_return(invalid_auth_log)

expect do
Ngrok::Wrapper.start(subdomain: 'test-subdomain', authtoken: 'incorrect_token')
Ngrok::Wrapper.start(authtoken: 'incorrect_token')
end.to raise_error Ngrok::Error
end
end
end

describe 'Custom hostname' do
describe 'when no authtoken is specified in ngrok config file' do
let(:no_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }

it 'raises Ngrok::Error exception' do
allow_any_instance_of(Tempfile).to receive(:read).and_return(no_auth_log)

expect { Ngrok::Wrapper.start(hostname: 'example.com') }.to raise_error Ngrok::Error
end
end

describe 'when an invalid authtoken is specified in ngrok config file' do
let(:invalid_auth_log) { File.read("#{RSPEC_ROOT}/fixtures/ngrok.no_auth_token.log") }

it 'raises Ngrok::Error exception' do
allow_any_instance_of(Tempfile).to receive(:read).and_return(invalid_auth_log)

expect { Ngrok::Wrapper.start(hostname: 'example.com', authtoken: 'incorrect_token') }
.to raise_error Ngrok::Error
end
end
end

describe 'Custom addr' do
before { allow_any_instance_of(Tempfile).to receive(:read).and_return(log) }

Expand Down Expand Up @@ -249,8 +226,10 @@
describe 'when fetching params returns nil' do
let(:state) { nil }

it 'tries fetching params of an already running Ngrok and store Ngrok process data into a file' do
it "doesn't check for similar ngroks running" do
expect(Ngrok::Wrapper).to receive(:try_params_from_running_ngrok)
expect(Ngrok::Wrapper).not_to receive(:raise_if_similar_ngroks)
expect(Ngrok::Wrapper).not_to receive(:ngrok_running?)
expect(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true)
expect(File).to receive(:write)

Expand Down Expand Up @@ -325,7 +304,7 @@
['835 ?? S 0:04.81 ngrok http -log -config /Users/thunder/.ngrok2/ngrok.yml https://localhost:3001']
end

it 'set Ngrok::Wrapper pid and status attributes' do
it 'sets Ngrok::Wrapper pid and status attributes' do
allow(Ngrok::Wrapper).to receive(:spawn_new_ngrok).with(persistent_ngrok: true).and_call_original
allow(Ngrok::Wrapper)
.to receive(:ngrok_process_status_lines).with(refetch: true).and_return(new_ngrok_ps_lines)
Expand Down