Skip to content

Commit

Permalink
Add an error message which points the user to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
swistak35 committed Jul 26, 2021
1 parent 37c28d9 commit 06b8da5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ruby_event_store/lib/ruby_event_store/in_memory_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
require 'ostruct'
module RubyEventStore
class InMemoryRepository
UnsupportedVersionAnyUsage = Class.new(StandardError)
class UnsupportedVersionAnyUsage < StandardError
def initialize
super <<~EOS
Mixing expected version :any and specific position (or :auto) is unsupported.
Read more about expected versions here:
https://railseventstore.org/docs/v2/expected_version/
EOS
end
end

class EventInStream
def initialize(event_id, position)
Expand Down
11 changes: 11 additions & 0 deletions ruby_event_store/spec/in_memory_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ module RubyEventStore
end.to raise_error(RubyEventStore::InMemoryRepository::UnsupportedVersionAnyUsage)
end

it 'message for UnsupportedVersionAnyUsage' do
expect(InMemoryRepository::UnsupportedVersionAnyUsage.new.message).to eq(
<<~EOS
Mixing expected version :any and specific position (or :auto) is unsupported.
Read more about expected versions here:
https://railseventstore.org/docs/v2/expected_version/
EOS
)
end

# This test only documents the 2.x behavior
it 'publishing with any position to stream with specific position' do
repository = InMemoryRepository.new(ensure_supported_any_usage: false)
Expand Down

0 comments on commit 06b8da5

Please sign in to comment.