Sha256: 8ef55d52c6904626b373689f8cb45f5ba8d46b11f78b7e659a7d886246c924f7
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true RSpec.describe FiniteMachine, perf: true do include RSpec::Benchmark::Matchers class Measurement attr_reader :steps, :loops def initialize @steps = 0 @loops = 0 end def inc_step @steps += 1 end def inc_loop @loops += 1 end end it "correctly loops through events" do measurement = Measurement.new fsm = FiniteMachine.new(measurement) do initial :green event :next, :green => :yellow, :yellow => :red, :red => :green on_enter do |event| target.inc_step; true end on_enter :red do |event| target.inc_loop; true end end 100.times { fsm.next } expect(measurement.steps).to eq(100) expect(measurement.loops).to eq(100 / 3) end it "performs at least 400 ips" do fsm = FiniteMachine.new do initial :green event :next, :green => :yellow, :yellow => :red, :red => :green end expect { fsm.next }.to perform_at_least(400).ips end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finite_machine-0.12.1 | spec/performance/benchmark_spec.rb |
finite_machine-0.12.0 | spec/performance/benchmark_spec.rb |