Skip to content

Commit

Permalink
test State#finished?
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed May 23, 2024
1 parent 6cc0282 commit 69a0a96
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions spec/workflow/state_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 69a0a96

Please sign in to comment.