Skip to content
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
35 changes: 27 additions & 8 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,35 @@ name: Ruby CI

on: [push, pull_request]
jobs:
test:
rubocop:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'

- name: Bundler
run: bundle install

- name: Rubocop
run: bin/rubocop

rspec:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
gemfile:
[
'gemfiles/faraday1.gemfile',
'gemfiles/faraday2.gemfile',
]
- 'gemfiles/faraday1.gemfile'
- 'gemfiles/faraday2.gemfile'

# Faraday 0.x with Ruby 3.x not supported
exclude:
- ruby: '3.0'
Expand All @@ -31,15 +48,17 @@ jobs:
gemfile: gemfiles/faraday0.gemfile
- ruby: '3.3'
gemfile: gemfiles/faraday0.gemfile
- ruby: '3.4'
gemfile: gemfiles/faraday0.gemfile
runs-on: ${{ matrix.os }}
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake spec
- run: bin/rspec
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--color
--warnings
84 changes: 84 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
inherit_from: .rubocop_todo.yml

plugins:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 2.7
Exclude:
- bin/*
- gemfiles/*
- lib/netbox-client-ruby.rb

Gemspec/RequireMFA:
Enabled: false

#########
# STYLE #
#########

Style/Documentation:
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: consistent_comma

Style/AccessModifierDeclarations:
Enabled: false

#########
# RSPEC #
#########

RSpec/NotToNot:
EnforcedStyle: to_not

RSpec/MultipleMemoizedHelpers:
Max: 10

RSpec/MultipleExpectations:
Max: 10

RSpec/NestedGroups:
Max: 5

RSpec/ExampleLength:
Max: 7

RSpec/MetadataStyle:
EnforcedStyle: hash

RSpec/MessageSpies:
EnforcedStyle: receive

# Configure me :)
RSpec/NamedSubject:
Enabled: false

RSpec/ContextWording:
Enabled: false

RSpec/SubjectDeclaration:
Enabled: false

Style/OpenStructUse:
Enabled: false

RSpec/VerifiedDoubles:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false

RSpec/IteratedExpectation:
Enabled: false
60 changes: 60 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-09-29 22:04:50 UTC using RuboCop version 1.81.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
Lint/ReturnInVoidContext:
Exclude:
- 'lib/netbox_client_ruby/entity.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/netbox_client_ruby/entity.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'lib/netbox_client_ruby/entity.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CollectionQuerying:
Exclude:
- 'lib/netbox_client_ruby/entity.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/KeywordArgumentsMerging:
Exclude:
- 'lib/netbox_client_ruby/connection.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpArgument:
Exclude:
- 'lib/netbox_client_ruby/communication.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/netbox_client_ruby/entities.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'netbox-client-ruby.gemspec'
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ end
appraise 'faraday2' do
gem 'faraday', '< 3'
gem 'faraday-net_http_persistent'
remove_gem "faraday_middleware"
remove_gem 'faraday_middleware'
end
14 changes: 10 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ source 'https://rubygems.org'
# Specify your gem dependencies in netbox-client-ruby.gemspec
gemspec

# Dev libs
gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
gem 'ostruct'
gem 'pry'
gem 'rake'
gem 'rspec'
gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'simplecov'
gem 'warning'

# fallback to faraday 1.x in dev environment
gem 'faraday', '~> 1.10'
gem 'faraday_middleware'

# Dev tools / linter
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rake', require: false
gem 'rubocop-rspec', require: false
27 changes: 27 additions & 0 deletions bin/appraisal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'appraisal' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("appraisal", "appraisal")
27 changes: 27 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rake", "rake")
27 changes: 27 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rspec-core", "rspec")
27 changes: 27 additions & 0 deletions bin/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rubocop' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rubocop", "rubocop")
11 changes: 7 additions & 4 deletions gemfiles/faraday0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
source "https://rubygems.org"

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
gem "ostruct"
gem "pry"
gem "rake"
gem "rspec"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "simplecov"
gem "warning"
gem "faraday", "< 1.0"
gem "faraday_middleware", "< 1"
gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false

gemspec path: "../"
11 changes: 7 additions & 4 deletions gemfiles/faraday1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
source "https://rubygems.org"

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
gem "ostruct"
gem "pry"
gem "rake"
gem "rspec"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "simplecov"
gem "warning"
gem "faraday", "= 1.0"
gem "faraday_middleware", "< 2"
gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false

gemspec path: "../"
Loading