Add tests for `Retrospring::Version`

This commit is contained in:
Andreas Nedbal 2022-04-16 03:50:28 +02:00 committed by Andreas Nedbal
parent 7e8ba6c647
commit b5c40619be
1 changed files with 36 additions and 0 deletions

36
spec/lib/version_spec.rb Normal file
View File

@ -0,0 +1,36 @@
# frozen_string_literal: true
require "version"
RSpec.describe Retrospring::Version do
before(:each) do
allow(Retrospring::Version).to receive(:year) { 1984 }
allow(Retrospring::Version).to receive(:month) { 1 }
allow(Retrospring::Version).to receive(:day) { 1 }
allow(Retrospring::Version).to receive(:patch) { 0 }
end
describe "#to_s" do
context "without suffix" do
it "should return the correct version string" do
expect(Retrospring::Version.to_s).to eq("1984.0101.0")
end
end
context "with suffix" do
before(:each) do
allow(Retrospring::Version).to receive(:suffix) { "+shutdown" }
end
it "should return the correct version string" do
expect(Retrospring::Version.to_s).to eq("1984.0101.0+shutdown")
end
end
end
describe "#to_a" do
it "should return the correct version as array" do
expect(Retrospring::Version.to_a).to eq(["1984", "0101", "0"])
end
end
end