Class: Operandi::RSpec::Matchers::ExecuteStepsMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/operandi/rspec/matchers/execute_step.rb

Instance Method Summary collapse

Constructor Details

#initialize(names, ordered:) ⇒ ExecuteStepsMatcher

Returns a new instance of ExecuteStepsMatcher.



140
141
142
143
# File 'lib/operandi/rspec/matchers/execute_step.rb', line 140

def initialize(names, ordered:)
  @names = names
  @ordered = ordered
end

Instance Method Details

#descriptionObject



172
173
174
175
176
177
178
# File 'lib/operandi/rspec/matchers/execute_step.rb', line 172

def description
  if @ordered
    "execute steps #{@names.inspect} in order"
  else
    "execute steps #{@names.inspect}"
  end
end

#failure_messageObject



156
157
158
159
160
161
162
# File 'lib/operandi/rspec/matchers/execute_step.rb', line 156

def failure_message
  return tracking_not_available_message unless service_tracks_steps?
  return missing_steps_failure_message unless all_steps_executed?
  return order_failure_message unless order_matches?

  ""
end

#failure_message_when_negatedObject



164
165
166
167
168
169
170
# File 'lib/operandi/rspec/matchers/execute_step.rb', line 164

def failure_message_when_negated
  if @ordered
    "expected service not to execute steps #{@names.inspect} in that order"
  else
    "expected service not to execute steps #{@names.inspect}"
  end
end

#matches?(service) ⇒ Boolean

Returns:

  • (Boolean)


145
146
147
148
149
150
151
152
153
154
# File 'lib/operandi/rspec/matchers/execute_step.rb', line 145

def matches?(service)
  @service = service
  @missing_steps = []

  return false unless service_tracks_steps?
  return false unless all_steps_executed?
  return false unless order_matches?

  true
end