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
3 changes: 2 additions & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch: {}
schedule:
- cron: "0 21 * * 6"

Expand All @@ -21,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["4.0", "head"]
ruby: ["3.4", "4.0", "head"]

steps:
- name: Harden the runner (Audit all outbound calls)
Expand Down
18 changes: 14 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
require:
- rubocop-disable_syntax

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

AllCops:
TargetRubyVersion: 4.0
TargetRubyVersion: 3.4
NewCops: enable

# We use standard as a linter and formatter instead Rubocop.
Expand Down Expand Up @@ -346,6 +344,18 @@ RSpec/IndexedLet:
RSpec/NamedSubject:
Enabled: false

# Ignore example length
RSpec/ExampleLength:
Enabled: false

# Ignore maximum example group nesting
RSpec/NestedGroups:
Enabled: false

# Ignore subject after let declarations
RSpec/LeadingSubject:
Enabled: false

# Naming rules:

# Disable anonymous block forwarding.
Expand Down
2 changes: 1 addition & 1 deletion .standard.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby_version: 4.0
ruby_version: 3.4
9 changes: 5 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ GEM
rubocop-ast (1.49.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-disable_syntax (0.1.1)
rubocop (>= 1.50)
rubocop-disable_syntax (0.2.0)
lint_roller
rubocop (>= 1.72.0)
rubocop-performance (1.26.1)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
Expand Down Expand Up @@ -121,7 +122,7 @@ CHECKSUMS
rspec-support (3.13.6) sha256=2e8de3702427eab064c9352fe74488cc12a1bfae887ad8b91cba480ec9f8afb2
rubocop (1.82.1) sha256=09f1a6a654a960eda767aebea33e47603080f8e9c9a3f019bf9b94c9cab5e273
rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
rubocop-disable_syntax (0.1.1) sha256=fba0b24edbd3de049ccaac8473c18fed308b5bd991e389a3368965f6cb88edbb
rubocop-disable_syntax (0.2.0) sha256=1e61645773b3fc2f74e995ec65f605f7db59437c274fdfd4f385f60bf86af73e
rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
Expand All @@ -136,4 +137,4 @@ CHECKSUMS
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f

BUNDLED WITH
4.0.4
4.0.4
2 changes: 1 addition & 1 deletion errbit_plugin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = "Base to create an errbit plugin"
spec.homepage = "https://github.com/errbit/errbit_plugin"
spec.license = "MIT"
spec.required_ruby_version = ">= 4.0.0"
spec.required_ruby_version = ">= 3.4.0"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
Expand Down
4 changes: 2 additions & 2 deletions lib/errbit_plugin/issue_tracker_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def implements_instance_methods?
end
end

impl.all? { |value| value == true }
impl.all?(true)
end

def implements_class_methods?
Expand All @@ -50,7 +50,7 @@ def implements_class_methods?
end
end

impl.all? { |value| value == true }
impl.all?(true)
end

def instance
Expand Down
2 changes: 1 addition & 1 deletion lib/errbit_plugin/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Registry
def self.add_issue_tracker(klass)
key = klass.label

if issue_trackers.has_key?(key)
if issue_trackers.key?(key)
raise AlreadyRegisteredError,
"issue_tracker '#{key}' already registered"
end
Expand Down
64 changes: 33 additions & 31 deletions spec/errbit_plugin/issue_tracker_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def url
end

it "valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be true
expect(described_class.new(klass).valid?).to eq(true)
end
end

Expand Down Expand Up @@ -91,13 +91,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "says :not_inherited" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:not_inherited]]
expect(is.errors).to eq([[:not_inherited]])
end
end

Expand Down Expand Up @@ -137,13 +137,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement label method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:class_method_missing, :label]]
expect(is.errors).to eq([[:class_method_missing, :label]])
end
end

Expand Down Expand Up @@ -183,13 +183,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement icons method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:class_method_missing, :icons]]
expect(is.errors).to eq([[:class_method_missing, :icons]])
end
end

Expand Down Expand Up @@ -229,13 +229,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement fields method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:class_method_missing, :fields]]
expect(is.errors).to eq([[:class_method_missing, :fields]])
end
end

Expand Down Expand Up @@ -275,13 +275,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement configured? method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:instance_method_missing, :configured?]]
expect(is.errors).to eq([[:instance_method_missing, :configured?]])
end
end

Expand Down Expand Up @@ -321,13 +321,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement errors method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:instance_method_missing, :errors]]
expect(is.errors).to eq([[:instance_method_missing, :errors]])
end
end

Expand Down Expand Up @@ -367,12 +367,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement create_issue method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:instance_method_missing, :create_issue]]
expect(is.errors).to eq([[:instance_method_missing, :create_issue]])
end
end

Expand Down Expand Up @@ -413,12 +414,13 @@ def url
end

it "is valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be true
expect(described_class.new(klass).valid?).to eq(true)
end

it "not say not implement close_issue method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).not_to eql [[:instance_method_missing, :close_issue]]
expect(is.errors).not_to eq([[:instance_method_missing, :close_issue]])
end
end

Expand Down Expand Up @@ -458,13 +460,13 @@ def close_issue
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement url method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:instance_method_missing, :url]]
expect(is.errors).to eq([[:instance_method_missing, :url]])
end
end

Expand Down Expand Up @@ -504,13 +506,13 @@ def url
end

it "not valid" do
expect(ErrbitPlugin::IssueTrackerValidator.new(klass).valid?).to be false
expect(described_class.new(klass).valid?).to eq(false)
end

it "say not implement note method" do
is = ErrbitPlugin::IssueTrackerValidator.new(klass)
is = described_class.new(klass)
is.valid?
expect(is.errors).to eql [[:class_method_missing, :note]]
expect(is.errors).to eq([[:class_method_missing, :note]])
end
end
end
Expand Down
37 changes: 20 additions & 17 deletions spec/errbit_plugin/registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

RSpec.describe ErrbitPlugin::Registry do
before do
ErrbitPlugin::Registry.clear_issue_trackers
described_class.clear_issue_trackers
end

let(:tracker) {
let(:tracker) do
tracker = Class.new(ErrbitPlugin::IssueTracker) do
def self.label
"something"
end
end

tracker
}
end

describe ".add_issue_tracker" do
context "with issue_tracker class valid" do
Expand All @@ -24,18 +25,22 @@ def self.label
.with(tracker)
.and_return(double(valid?: true, message: ""))
end

it "add new issue_tracker plugin" do
ErrbitPlugin::Registry.add_issue_tracker(tracker)
expect(ErrbitPlugin::Registry.issue_trackers).to eq({
described_class.add_issue_tracker(tracker)

expect(described_class.issue_trackers).to eq({
"something" => tracker
})
end

context "with already issue_tracker with this key" do
it "raise ErrbitPlugin::AlreadyRegisteredError" do
ErrbitPlugin::Registry.add_issue_tracker(tracker)
expect {
ErrbitPlugin::Registry.add_issue_tracker(tracker)
}.to raise_error(ErrbitPlugin::AlreadyRegisteredError)
described_class.add_issue_tracker(tracker)

expect do
described_class.add_issue_tracker(tracker)
end.to raise_error(ErrbitPlugin::AlreadyRegisteredError)
end
end
end
Expand All @@ -46,9 +51,10 @@ def self.label
.to receive(:new)
.with(tracker)
.and_return(double(valid?: false, message: "foo", errors: []))
expect {
ErrbitPlugin::Registry.add_issue_tracker(tracker)
}.to raise_error(ErrbitPlugin::IncompatibilityError)

expect do
described_class.add_issue_tracker(tracker)
end.to raise_error(ErrbitPlugin::IncompatibilityError)
end

it "puts the errors in the exception message" do
Expand All @@ -57,11 +63,8 @@ def self.label
.with(tracker)
.and_return(double(valid?: false, message: "foo", errors: ["one", "two"]))

begin
ErrbitPlugin::Registry.add_issue_tracker(tracker)
rescue ErrbitPlugin::IncompatibilityError => e
expect(e.message).to eq("one; two")
end
expect { described_class.add_issue_tracker(tracker) }
.to raise_error(ErrbitPlugin::IncompatibilityError, "one; two")
end
end
end
Expand Down