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.



6
7
8
9
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 6

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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



42
43
44
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 42

def count
  @count
end

#eventsObject (readonly)

Returns the value of attribute events.



42
43
44
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 42

def events
  @events
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 17

def empty?
  events.empty?
end

#eventObject

Raises:



37
38
39
40
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 37

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

#exactly(count) ⇒ Object

Raises:



11
12
13
14
15
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 11

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

#onceObject



21
22
23
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 21

def once
  exactly(1)
end

#specified_count?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 25

def specified_count?
  !count.nil?
end

#strictObject



29
30
31
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 29

def strict
  @strict = true
end

#strict?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ruby_event_store/rspec/expected_collection.rb', line 33

def strict?
  @strict
end