Skip to content

Commit b61b4cb

Browse files
committed
Breaking internals is not breaking
1 parent 740764f commit b61b4cb

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ruby_event_store/lib/ruby_event_store/specification.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Specification
2222
) do
2323
def limit? = !limit.infinite?
2424
def with_ids? = !with_ids.nil?
25-
def with_types? = !with_types.nil?
25+
def with_types? = !with_types.empty?
2626
def forward? = direction.equal?(:forward)
2727
def backward? = direction.equal?(:backward)
2828
def batched? = read_as.equal?(:batch)
@@ -53,7 +53,7 @@ def initialize(
5353
read_as: :all,
5454
batch_size: DEFAULT_BATCH_SIZE,
5555
with_ids: nil,
56-
with_types: nil,
56+
with_types: [],
5757
)
5858
)
5959
@reader = reader
@@ -313,8 +313,7 @@ def last
313313
# @types [Class, Array(Class)] types of event to look for.
314314
# @return [Specification]
315315
def of_type(*types)
316-
types_ = types.flatten.map(&:to_s) unless types.empty?
317-
Specification.new(reader, result.with(with_types: types_))
316+
Specification.new(reader, result.with(with_types: types.flatten.map(&:to_s)))
318317
end
319318
alias of_types of_type
320319

ruby_event_store/spec/specification_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ module RubyEventStore
6767
specify { expect(specification.with_id([event_id]).result.with_ids?).to be(true) }
6868
specify { expect(specification.with_id([]).result.with_ids?).to be(true) }
6969

70-
specify { expect(specification.result.with_types).to be_nil }
71-
specify { expect(specification.of_type.result.with_types).to be_nil }
70+
specify { expect(specification.result.with_types).to eq([]) }
71+
specify { expect(specification.of_type.result.with_types).to eq([]) }
7272
specify { expect(specification.of_type([TestEvent]).result.with_types).to eq(["TestEvent"]) }
7373
specify { expect(specification.result.with_types?).to be(false) }
7474
specify { expect(specification.of_type([TestEvent]).result.with_types?).to be(true) }

0 commit comments

Comments
 (0)