Sha256: 65e912ec79d8c5d04a9b81c42f6a2b55495bf8e0b081ddcb3d6e83885ecf839d

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

module MiniTest::Assertions
  def assert_activity_inspect(text, subject)
    Trailblazer::Circuit::ActivityInspect(subject).must_equal text
  end

  def assert_event_inspect(text, subject)
    Trailblazer::Circuit::EndInspect(subject).must_equal(text)
  end
end


Trailblazer::Circuit::Activity.infect_an_assertion :assert_activity_inspect, :must_inspect
Trailblazer::Circuit::End.infect_an_assertion      :assert_event_inspect,    :must_inspect_end_fixme

class Trailblazer::Circuit
  def self.EndInspect(event)
    event.instance_eval { "#<#{self.class.to_s.split("::").last}: #{@name} #{@options}>" }
  end

  def self.ActivityInspect(activity, strip: ["AlterTest::"])
    strip += ["Trailblazer::Circuit::"]
    stripped = ->(target) { strip_for(target, strip) }

    map, _ = activity.circuit.to_fields

    content = map.collect do |task, connections|
      bla =
      connections.collect do |direction, target|
        target_str = target.kind_of?(End) ? EndInspect(target) : stripped.(target)
        "#{stripped.(direction)}=>#{target_str}"
      end.join(", ")
      task_str = task.kind_of?(End) ? EndInspect(task) : stripped.(task)
      "#{task_str}=>{#{bla}}"
    end.join(", ")
    "{#{content}}"
  end

  def self.strip_for(target, strings)
    strings.each { |stripped| target = target.to_s.gsub(stripped, "") }
    target
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
trailblazer-circuit-0.0.11 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.10 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.9 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.8 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.7 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.6 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.5 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.4 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.3 lib/trailblazer/circuit/testing.rb
trailblazer-circuit-0.0.2 lib/trailblazer/circuit/testing.rb