Retrospring/spec/lib/version_spec.rb

37 lines
985 B
Ruby
Raw Normal View History

2022-04-15 18:50:28 -07:00
# 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