From 69a0a9638d19ef0df6548b4d34eefd661d649f2a Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 23 May 2024 14:03:37 -0400 Subject: [PATCH] test State#finished? --- spec/workflow/state_spec.rb | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 spec/workflow/state_spec.rb diff --git a/spec/workflow/state_spec.rb b/spec/workflow/state_spec.rb new file mode 100644 index 00000000..d340d896 --- /dev/null +++ b/spec/workflow/state_spec.rb @@ -0,0 +1,45 @@ +RSpec.describe Floe::Workflow::State do + let(:input) { {} } + let(:ctx) { Floe::Workflow::Context.new(:input => input) } + let(:state) { workflow.current_state } + # picked a state that doesn't instantly finish + let(:workflow) { make_workflow(ctx, {"WaitState" => {"Type" => "Wait", "Seconds" => 1, "Next" => "SuccessState"}, "SuccessState" => {"Type" => "Succeed"}}) } + + describe "#started?" do + it "is not started yet" do + expect(state.started?).to eq(false) + end + + it "is started" do + state.start(ctx.input) + expect(state.started?).to eq(true) + end + + it "is finished" do + state.start(ctx.input) + state.finish + + state.start(ctx.input) + expect(state.started?).to eq(true) + end + end + + describe "#finished?" do + it "is not started yet" do + expect(state.finished?).to eq(false) + end + + it "is started" do + state.start(ctx.input) + expect(state.finished?).to eq(false) + end + + it "is finished" do + state.start(ctx.input) + state.finish + + state.start(ctx.input) + expect(state.finished?).to eq(true) + end + end +end