Class: RubyEventStore::RSpec::ExpectedCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/rspec/expected_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ ExpectedCollection

Returns a new instance of ExpectedCollection.


4
5
6
7
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 4

def initialize(events)
  @events = events
  @strict = false
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.


40
41
42
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 40

def count
  @count
end

#eventsObject (readonly)

Returns the value of attribute events.


40
41
42
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 40

def events
  @events
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 15

def empty?
  events.empty?
end

#eventObject

Raises:


35
36
37
38
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 35

def event
  raise NotSupported if !events.size.equal?(1)
  events.first
end

#exactly(count) ⇒ Object

Raises:


9
10
11
12
13
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 9

def exactly(count)
  raise NotSupported if !events.size.equal?(1)
  raise NotSupported if count < 1
  @count = count
end

#onceObject


19
20
21
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 19

def once
  exactly(1)
end

#specified_count?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 23

def specified_count?
  !count.nil?
end

#strictObject


27
28
29
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 27

def strict
  @strict = true
end

#strict?Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 31

def strict?
  @strict
end