module Crabfarm::RSpec::ReducerSpecHelpers

Public Instance Methods

reduce(_snapshot, _params={}) click to toggle source
# File lib/crabfarm/rspec/reducer_spec_helpers.rb, line 5
def reduce(_snapshot, _params={})
  ensure_reducer_for :reduce
  raise ArgumentError.new 'Must provide a snapshot for reducer specs' if _snapshot.nil?

  snap_path = described_class.snapshot_path _snapshot
  raise ArgumentError.new "Snapshot does not exist #{snap_path}" unless File.exist? snap_path

  reducer = Factories::SnapshotReducer.build described_class, snap_path, (_params || {})
  reducer.run
  reducer
end
reducer() click to toggle source
# File lib/crabfarm/rspec/reducer_spec_helpers.rb, line 17
def reducer
  @reducer_state ||= reduce @reducer_snapshot, @reducer_params
end

Private Instance Methods

ensure_reducer_for(_name) click to toggle source
# File lib/crabfarm/rspec/reducer_spec_helpers.rb, line 23
def ensure_reducer_for(_name)
  raise "'#{_name}' is only available in reducer specs." unless described_class < Crabfarm::BaseReducer
end