Sha256: 6c9d5def182dbe7a9b7cc1ac24bd574f84836a61fc1e0ea7adf947d789c68f45
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true RSpec.describe FiniteMachine::EventsMap, '#match_transition' do it "matches transition without conditions" do transition_a = double(:transition_a, matches?: false) transition_b = double(:transition_b, matches?: true) events_map = described_class.new events_map.add(:a, transition_a) events_map.add(:a, transition_b) expect(events_map.match_transition(:a, :green)).to eq(transition_b) end it "fails to match any transition" do events_map = described_class.new expect(events_map.match_transition(:a, :green)).to eq(nil) end it "matches transition with conditions" do transition_a = double(:transition_a, matches?: true) transition_b = double(:transition_b, matches?: true) events_map = described_class.new events_map.add(:a, transition_a) events_map.add(:a, transition_b) allow(transition_a).to receive(:check_conditions).and_return(false) allow(transition_b).to receive(:check_conditions).and_return(true) expect(events_map.match_transition_with(:a, :green, 'Piotr')).to eq(transition_b) expect(transition_a).to have_received(:check_conditions).with('Piotr') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finite_machine-0.12.1 | spec/unit/events_map/match_transition_spec.rb |
finite_machine-0.12.0 | spec/unit/events_map/match_transition_spec.rb |