|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | RSpec.describe Mars::Gate do |
4 | | - describe "#initialize" do |
5 | | - let(:condition) { ->(input) { input > 5 } } |
6 | | - let(:branches) { { true => Mars::Exit.new, false => Mars::Exit.new } } |
7 | | - |
8 | | - it "initializes with required parameters" do |
9 | | - gate = described_class.new(name: "TestGate", condition: condition, branches: branches) |
10 | | - expect(gate.name).to eq("TestGate") |
11 | | - end |
12 | | - |
13 | | - it "requires a name parameter" do |
14 | | - expect do |
15 | | - described_class.new(condition: condition, branches: branches) |
16 | | - end.to raise_error(ArgumentError) |
17 | | - end |
18 | | - |
19 | | - it "requires a condition parameter" do |
20 | | - expect do |
21 | | - described_class.new(name: "TestGate", branches: branches) |
22 | | - end.to raise_error(ArgumentError) |
23 | | - end |
24 | | - |
25 | | - it "requires a branches parameter" do |
26 | | - expect do |
27 | | - described_class.new(name: "TestGate", condition: condition) |
28 | | - end.to raise_error(ArgumentError) |
29 | | - end |
30 | | - end |
31 | | - |
32 | | - describe "#name" do |
33 | | - let(:condition) { ->(input) { input > 5 } } |
34 | | - let(:branches) { { true => Mars::Exit.new } } |
35 | | - |
36 | | - it "returns the gate name" do |
37 | | - gate = described_class.new(name: "MyGate", condition: condition, branches: branches) |
38 | | - expect(gate.name).to eq("MyGate") |
39 | | - end |
40 | | - end |
41 | | - |
42 | 4 | describe "#run" do |
43 | 5 | context "with simple boolean condition" do |
44 | 6 | let(:condition) { ->(input) { input > 5 } } |
|
175 | 137 | end |
176 | 138 | end |
177 | 139 | end |
178 | | - |
179 | | - describe "inheritance" do |
180 | | - it "inherits from Mars::Runnable" do |
181 | | - expect(described_class.ancestors).to include(Mars::Runnable) |
182 | | - end |
183 | | - end |
184 | 140 | end |
0 commit comments