Skip to content

Commit

Permalink
Fix RES Browser being unusable
Browse files Browse the repository at this point in the history
Two problems contributed to the issue:

  * two–digit number appeared in the version number (2.11.0)
  * version number itself contained only two sections instead of three
    (2.10)

Testing with current RubyEvenStore::VERSION contributes to preventing
such issues in the future.

#1647

Co-authored-by: Paweł Pacana <[email protected]>
  • Loading branch information
fidel and mostlyobvious committed Jul 25, 2023
1 parent 9730a76 commit 514e001
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(load_path)
@path =
load_path
.select { |entry| String === entry }
.find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d\.\d\.\d)?/lib\z} }
.find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d+\.\d+\.\d+)?/lib\z} }
end

def version
Expand All @@ -21,7 +21,7 @@ def version
end

def from_rubygems?
path.match? %r{/gems/ruby_event_store-browser-\d\.\d\.\d/lib\z}
path.match? %r{/gems/ruby_event_store-browser-\d+\.\d+\.\d+/lib\z}
end

def from_git?
Expand Down
8 changes: 8 additions & 0 deletions ruby_event_store-browser/spec/gem_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ module Browser
expect(source).to be_from_git
end

specify "don't crash on two–digit number in version string" do
path = "/Users/mostlyobvious/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/ruby_event_store-browser-#{RubyEventStore::VERSION}/lib"
source = GemSource.new([random_unrelated_path, path])

expect(source.version).to eq(RubyEventStore::VERSION)
expect(source).not_to be_from_git
end

def random_unrelated_path
"/kaka/dudu"
end
Expand Down

0 comments on commit 514e001

Please sign in to comment.