Class: LiquidStream::Matchers::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid_stream/matchers/stream.rb

Instance Method Summary collapse

Constructor Details

#initialize(attr_name) ⇒ Stream

Returns a new instance of Stream.



4
5
6
# File 'lib/liquid_stream/matchers/stream.rb', line 4

def initialize(attr_name)
  @attr_name = attr_name
end

Instance Method Details

#as(as) ⇒ Object



13
14
15
16
# File 'lib/liquid_stream/matchers/stream.rb', line 13

def as(as)
  @as = as
  self
end

#descriptionObject



26
27
28
# File 'lib/liquid_stream/matchers/stream.rb', line 26

def description
  "Ensures that #{@klass} streams #{@attr_name}."
end

#failure_messageObject



18
19
20
21
22
23
24
# File 'lib/liquid_stream/matchers/stream.rb', line 18

def failure_message
  base_message = %Q(expected #{@klass} to stream `#{@attr_name}`)
  if defined? @as
    base_message += " as `#{@as}`"
  end
  base_message
end

#matches?(klass) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/liquid_stream/matchers/stream.rb', line 8

def matches?(klass)
  @klass = klass
  key_exists? && options_correct?
end