Fix up some Rubocop things, stub out reserved domain spec

This commit is contained in:
David Parker
2021-09-13 09:03:00 -06:00
parent 224c0ad217
commit 99245c38e2
9 changed files with 148 additions and 26 deletions
+14
View File
@@ -2,11 +2,25 @@ inherit_from:
- .rubocop_airbnb.yml
- .rubocop_todo.yml
Metrics/LineLength:
Max: 100
# Ignore Rails-y Airbnb recommendation
Airbnb/ClassOrModuleDeclaredInWrongFile:
Enabled: false
# Ignore Rails-y Airbnb recommendation
Airbnb/ConstAssignedInWrongFile:
Enabled: false
# Allow empty examples to stub out specs
RSpec/EmptyExampleGroup:
Enabled: false
# Allow fake tests to stub out specs
RSpec/ExpectActual:
Enabled: false
# It just looks nicer
Layout/AlignArguments:
EnforcedStyle: with_fixed_indentation
+9 -1
View File
@@ -6,6 +6,8 @@ Documentation can be generated with the command:
yard doc 'lib/**/*.rb'
```
This will generate a documentation which can be viewed within the doc folder.
# Specs
Specs can be run with the command:
@@ -14,10 +16,16 @@ Specs can be run with the command:
bundle exec rake
```
This will generate a coverage report which can be viewed within the coverage folder.
# Rubocop
Rubocop can be run with the command:
```sh
```ruby
# Run rubocop on lib folder
rubocop 'lib'
# Run rubcop on all files
rubocop
```
+8 -7
View File
@@ -79,17 +79,10 @@ module NgrokAPI
https_endpoint_configuration_id: nil,
metadata: ''
)
@certificate_id = certificate_id if certificate_id
if certificate_management_policy
@certificate_management_policy = certificate_management_policy
end
@description = description if description
if http_endpoint_configuration_id
@http_endpoint_configuration_id = http_endpoint_configuration_id
end
if https_endpoint_configuration_id
@https_endpoint_configuration_id = https_endpoint_configuration_id
end
@metadata = metadata if metadata
@client.update(
id: @id,
@@ -100,6 +93,14 @@ module NgrokAPI
certificate_id: certificate_id,
certificate_management_policy: certificate_management_policy
)
# TODO: update @certificate, etc?
# @certificate = new_result['certificate'] if certificate_id && new_result['certificate']
# if http_endpoint_configuration_id
# @http_endpoint_configuration_id = http_endpoint_configuration_id
# end
# if https_endpoint_configuration_id
# @https_endpoint_configuration_id = https_endpoint_configuration_id
# end
end
##
+4 -3
View File
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'ngrokapi/version'
@@ -13,12 +14,12 @@ Gem::Specification.new do |s|
s.summary = 'Summary of the Ngrok Ruby API.'
s.description = 'Description of the Ngrok Ruby API.'
s.required_ruby_version = '>= 3.0.0'
s.required_ruby_version = '>= 3.0.0'
all_files = `git ls-files`.split("\n")
test_files = `git ls-files -- {test,spec,features}/*`.split('\n')
s.files = all_files - test_files
s.executables = `git ls-files -- bin/*`.split('\n').map { |f| File.basename(f) }
s.files = all_files - test_files
s.executables = `git ls-files -- bin/*`.split('\n').map { |f| File.basename(f) }
s.require_paths = ['lib']
end
+7 -4
View File
@@ -9,7 +9,7 @@ RSpec.describe NgrokAPI::Models::ApiKey do
"description" => "",
"metadata" => "",
"created_at" => "2021-09-08T17:49:56Z",
"token" => nil
"token" => nil,
}
@api_key = NgrokAPI::Models::ApiKey.new(client: client, result: result)
end
@@ -27,19 +27,22 @@ RSpec.describe NgrokAPI::Models::ApiKey do
end
describe "#delete" do
it "should call delete on the client" do
it "calls delete on the client" do
expect(@api_key.client).to receive(:delete)
@api_key.delete
end
end
describe "#update" do
it "should update the instance's description and metadata and call update on the client" do
it "updates instance's description and metadata and call update on the client" do
new_description = 'new description'
new_metadata = 'new metadata'
expect(@api_key.client).to receive(:update)
@api_key.update(description: new_description, metadata: new_metadata)
@api_key.update(
description: new_description,
metadata: new_metadata,
)
expect(@api_key.description).to eq new_description
expect(@api_key.metadata).to eq new_metadata
end
+6 -6
View File
@@ -4,14 +4,14 @@ RSpec.describe NgrokAPI::Models::Listable do
before(:each) do
client = class_double("ApiKeysClient")
@result = {
"keys"=> [
"keys" => [
{
"id" => "ak_1xSR6lmGzdXyfOsubPGwnuaBUfN",
"uri" => "https://api.ngrok.com/api_keys/ak_1xSR6lmGzdXyfOsubPGwnuaBUfN",
"description" => "testkey",
"metadata" => "Cool",
"created_at" => "2021-08-30T17:58:49Z",
"token" => nil
"token" => nil,
},
{
"id" => "ak_1xrqAsg8fMHBgD71MSbtr6a0pA2",
@@ -19,7 +19,7 @@ RSpec.describe NgrokAPI::Models::Listable do
"description" => "",
"metadata" => "",
"created_at" => "2021-09-08T17:50:14Z",
"token" => nil
"token" => nil,
},
{
"id" => "ak_1xrq9HdabkhmGN4It9Lx7zuSUF2",
@@ -27,11 +27,11 @@ RSpec.describe NgrokAPI::Models::Listable do
"description" => "",
"metadata" => "",
"created_at" => "2021-09-08T17:50:01Z",
"token" => nil
}
"token" => nil,
},
],
"uri" => "https://api.ngrok.com/api_keys",
"next_page_uri" => nil
"next_page_uri" => nil,
}
@listable = NgrokAPI::Models::Listable.new(
client: client,
@@ -0,0 +1,96 @@
require 'spec_helper'
RSpec.describe NgrokAPI::Models::ReservedDomain do
before(:each) do
client = class_double("ReservedDomainsClient")
result = {
"id" => "rd_1xxLksFRG6o5MoAKX8UrtPnXbmz",
"uri" => "https://api.ngrok.com/reserved_domains/rd_1xxLksFRG6o5MoAKX8UrtPnXbmz",
"created_at" => "2021-09-10T16:38:58Z",
"description" => "",
"metadata" => "",
"domain" => "tahouetnaoh.ngrok.io",
"region" => "us",
"cname_target" => nil,
"http_endpoint_configuration" => {
"id" => "ec_1xv9oZpu0g1sbaZvxuqKQJVCLW5",
"uri" => "https://api.ngrok.com/endpoint_configurations/ec_1xv9oZpu0g1sbaZvxuqKQJVCLW5",
},
"https_endpoint_configuration" => nil,
"certificate" => nil,
"certificate_management_policy" => nil,
"certificate_management_status" => nil,
}
@domain = NgrokAPI::Models::ReservedDomain.new(client: client, result: result)
end
describe "#==" do
pending "should be equal if X" do
expect(1).to eq 2
end
end
describe "#to_s" do
pending "should stringify with X" do
expect(1).to eq 2
end
end
describe "#delete" do
it "calls delete on the client" do
expect(@domain.client).to receive(:delete)
@domain.delete
end
end
describe "#update" do
it "updates the instance's description and metadata and call update on the client" do
# new_certificate_id = 'new certificate_id'
# new_http_endpoint_configuration_id = 'new http_endpoint_configuration_id'
# new_https_endpoint_configuration_id = 'new https_endpoint_configuration_id'
new_certificate_management_policy = 'new certificate_management_policy'
new_description = 'new description'
new_metadata = 'new metadata'
expect(@domain.client).to receive(:update)
# certificate_id: new_certificate_id,
# http_endpoint_configuration_id: new_http_endpoint_configuration_id,
# https_endpoint_configuration_id: new_https_endpoint_configuration_id
@domain.update(
description: new_description,
metadata: new_metadata,
certificate_management_policy: new_certificate_management_policy
)
expect(@domain.description).to eq new_description
expect(@domain.metadata).to eq new_metadata
expect(@domain.certificate_management_policy).to eq new_certificate_management_policy
# expect(@domain.certificate_id).to eq new_certificate_id
# expect(@domain.http_endpoint_configuration_id).to eq new_http_endpoint_configuration_id
# expect(@domain.https_endpoint_configuration_id).to eq new_https_endpoint_configuration_id
end
end
describe "#delete_certificate" do
end
describe "#delete_certificate_management_policy" do
end
describe "#delete_http_endpoint_config" do
end
describe "#delete_https_endpoint_config" do
end
describe "#restore_certificate" do
end
describe "#restore_certificate_management_policy" do
end
describe "#restore_http_endpoint_config" do
end
describe "#restore_https_endpoint_config" do
end
end
@@ -1,10 +1,6 @@
require 'spec_helper'
RSpec.describe NgrokAPI::Services::ApiKeysClient do
before(:each) do
end
describe "#create" do
pending "should" do
expect(1).to eq 2
+4 -1
View File
@@ -1,4 +1,5 @@
# frozen_string_literal: true
require "simplecov"
SimpleCov.start
require 'pry'
@@ -6,7 +7,9 @@ require 'pry'
require 'webmock/rspec'
require './lib/ngrokapi'
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each {|f| require f}
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each do |f|
require f
end
RSpec.configure do |config|
config.expect_with :rspec do |expectations|