Skip to content

Commit

Permalink
DEV: Update linting setup (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
CvX authored Jun 19, 2024
1 parent f228617 commit d5ea30b
Show file tree
Hide file tree
Showing 23 changed files with 265 additions and 259 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
ruby-version: "3.3"
bundler-cache: true

- name: Rubocop
Expand All @@ -32,10 +32,10 @@ jobs:

strategy:
matrix:
ruby: ['2.7', '3.0', '3.1', '3.2']
ruby: ["2.7", "3.0", "3.1", "3.2", "3.3"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup ruby
uses: ruby/setup-ruby@v1
Expand All @@ -52,10 +52,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Release Gem
uses: discourse/publish-rubygems-action@v2
uses: discourse/publish-rubygems-action@v3
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
GIT_EMAIL: team@discourse.org
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
inherit_gem:
rubocop-discourse: stree-compat.yml

Discourse/Plugins:
Enabled: false
2 changes: 1 addition & 1 deletion .streerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--print-width=100
--plugins=plugin/trailing_comma,disable_ternary
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
67 changes: 36 additions & 31 deletions discourse_api.gemspec
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
# frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'discourse_api/version'

lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
require "discourse_api/version"

Gem::Specification.new do |spec|
spec.name = 'discourse_api'
spec.version = DiscourseApi::VERSION
spec.authors = ['Sam Saffron', 'John Paul Ashenfelter', 'Michael Herold', 'Blake Erickson']
spec.email = ['sam.saffron@gmail.com', 'john@ashenfelter.com', 'michael.j.herold@gmail.com', 'o.blakeerickson@gmail.com']
spec.description = 'Discourse API'
spec.summary = 'Allows access to the Discourse API'
spec.homepage = 'http://github.com/discourse/discourse_api'
spec.license = 'MIT'
spec.name = "discourse_api"
spec.version = DiscourseApi::VERSION
spec.authors = ["Sam Saffron", "John Paul Ashenfelter", "Michael Herold", "Blake Erickson"]
spec.email = %w[
sam.saffron@gmail.com
john@ashenfelter.com
michael.j.herold@gmail.com
o.blakeerickson@gmail.com
]
spec.description = "Discourse API"
spec.summary = "Allows access to the Discourse API"
spec.homepage = "http://github.com/discourse/discourse_api"
spec.license = "MIT"

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_runtime_dependency 'faraday', '~> 2.7'
spec.add_runtime_dependency 'faraday-follow_redirects'
spec.add_runtime_dependency 'faraday-multipart'
spec.add_runtime_dependency 'rack', '>= 1.6'
spec.add_runtime_dependency "faraday", "~> 2.7"
spec.add_runtime_dependency "faraday-follow_redirects"
spec.add_runtime_dependency "faraday-multipart"
spec.add_runtime_dependency "rack", ">= 1.6"

spec.add_development_dependency 'bundler', '~> 2.0'
spec.add_development_dependency 'guard', '~> 2.14'
spec.add_development_dependency 'guard-rspec', '~> 4.7'
spec.add_development_dependency 'rake', '>= 12.3.3'
spec.add_development_dependency 'rb-inotify', '~> 0.9'
spec.add_development_dependency 'rspec', '~> 3.4'
spec.add_development_dependency 'simplecov', '~> 0.11'
spec.add_development_dependency 'webmock', '~> 3.0'
spec.add_development_dependency 'rubocop-discourse', '~> 3.2.0'
spec.add_development_dependency 'syntax_tree', '~> 6.1.1'
spec.add_development_dependency 'syntax_tree-disable_ternary', '~> 1.0.0'
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "guard", "~> 2.14"
spec.add_development_dependency "guard-rspec", "~> 4.7"
spec.add_development_dependency "rake", ">= 12.3.3"
spec.add_development_dependency "rb-inotify", "~> 0.9"
spec.add_development_dependency "rspec", "~> 3.4"
spec.add_development_dependency "simplecov", "~> 0.11"
spec.add_development_dependency "webmock", "~> 3.0"
spec.add_development_dependency "rubocop-discourse", "= 3.8.1"
spec.add_development_dependency "syntax_tree", "~> 6.2.0"

spec.required_ruby_version = '>= 2.7.0'
spec.required_ruby_version = ">= 2.7.0"
end
22 changes: 11 additions & 11 deletions spec/discourse_api/api/api_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "spec_helper"

describe DiscourseApi::API::ApiKey do
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }

describe "#list_api_keys" do
before do
Expand All @@ -16,13 +16,13 @@
end

it "requests the correct resource" do
subject.list_api_keys
client.list_api_keys
url = "#{host}/admin/api/keys"
expect(a_get(url)).to have_been_made
end

it "returns the requested api keys" do
keys = subject.list_api_keys
keys = client.list_api_keys
expect(keys["keys"]).to be_an Array
expect(keys["keys"].first).to be_a Hash
expect(keys["keys"].first).to have_key("key")
Expand All @@ -41,13 +41,13 @@
end

it "requests the correct resource" do
subject.create_api_key(key: { username: "robin" })
client.create_api_key(key: { username: "robin" })
url = "#{host}/admin/api/keys"
expect(a_post(url)).to have_been_made
end

it "returns the generated api key" do
api_key = subject.create_api_key(key: { username: "robin" })
api_key = client.create_api_key(key: { username: "robin" })
expect(api_key).to be_a Hash
expect(api_key["key"]).to have_key("key")
end
Expand All @@ -65,13 +65,13 @@
end

it "requests the correct resource" do
subject.revoke_api_key(10)
client.revoke_api_key(10)
url = "#{host}/admin/api/keys/10/revoke"
expect(a_post(url)).to have_been_made
end

it "returns the api key" do
api_key = subject.revoke_api_key(10)
api_key = client.revoke_api_key(10)
expect(api_key["key"]).to have_key("key")
end
end
Expand All @@ -88,13 +88,13 @@
end

it "requests the correct resource" do
subject.undo_revoke_api_key(10)
client.undo_revoke_api_key(10)
url = "#{host}/admin/api/keys/10/undo-revoke"
expect(a_post(url)).to have_been_made
end

it "returns the api key" do
api_key = subject.undo_revoke_api_key(10)
api_key = client.undo_revoke_api_key(10)
expect(api_key["key"]).to have_key("key")
end
end
Expand All @@ -111,13 +111,13 @@
end

it "requests the correct resource" do
subject.delete_api_key(10)
client.delete_api_key(10)
url = "#{host}/admin/api/keys/10"
expect(a_delete(url)).to have_been_made
end

it "returns 200" do
response = subject.delete_api_key(10)
response = client.delete_api_key(10)
expect(response["status"]).to eq(200)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/discourse_api/api/backups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "spec_helper"

describe DiscourseApi::API::Backups do
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }

describe "#backups" do
before do
Expand All @@ -15,12 +15,12 @@
end

it "requests the correct resource" do
subject.backups
client.backups
expect(a_get("#{host}/admin/backups.json")).to have_been_made
end

it "returns the requested backups" do
backups = subject.backups
backups = client.backups
expect(backups).to be_an Array
expect(backups.first).to be_a Hash
expect(backups.first).to have_key("filename")
Expand Down
10 changes: 5 additions & 5 deletions spec/discourse_api/api/badges_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "spec_helper"

describe DiscourseApi::API::Badges do
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }

describe "#badges" do
before do
Expand All @@ -15,12 +15,12 @@
end

it "requests the correct resource" do
subject.badges
client.badges
expect(a_get("#{host}/admin/badges.json")).to have_been_made
end

it "returns the requested badges" do
badges = subject.badges
badges = client.badges
expect(badges).to be_a Hash
expect(badges["badges"]).to be_an Array
end
Expand All @@ -37,12 +37,12 @@
end

it "requests the correct resource" do
subject.user_badges("test_user")
client.user_badges("test_user")
expect(a_get("#{host}/user-badges/test_user.json")).to have_been_made
end

it "returns the requested user badges" do
badges = subject.user_badges("test_user")
badges = client.user_badges("test_user")
expect(badges).to be_an Array
expect(badges.first).to be_a Hash
expect(badges.first).to have_key("badge_type_id")
Expand Down
Loading

0 comments on commit d5ea30b

Please sign in to comment.