Add Order#filled? method

This commit is contained in:
Tim Kächele 2023-10-27 19:09:24 +02:00
parent f2f051c3a4
commit e92a3b1102
2 changed files with 30 additions and 0 deletions

View File

@ -25,5 +25,8 @@ module Rex
@next_order = nil @next_order = nil
end end
def filled?
remaining_amount == 0
end
end end
end end

27
spec/order_spec.rb Normal file
View File

@ -0,0 +1,27 @@
# frozen_string_literal: true
RSpec.describe Rex::Order do
describe "#filled?" do
let(:order) do
instance = described_class.new(
amount: 100
)
instance.remaining_amount = remaining_amount
instance
end
subject { order.filled? }
context "when remaining amount is not zero" do
let(:remaining_amount) { 50 }
it { is_expected.to be(false) }
end
context "when remaining amount is zero" do
let(:remaining_amount) { 0 }
it { is_expected.to be(true) }
end
end
end