mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 04:30:29 +00:00
Improve motd a hundred fold
Yes, I know this is a terrible feature. But it's been a long week and I'm so tired. Also fix the ordering in motd_spec. Who thought putting the month first was reasonable?
This commit is contained in:
parent
9f539dbd59
commit
045472577a
@ -5,6 +5,8 @@ elseif date.month == 12 and date.day == 24 then
|
||||
print("Merry X-mas!")
|
||||
elseif date.month == 10 and date.day == 31 then
|
||||
print("OOoooOOOoooo! Spooky!")
|
||||
elseif date.month == 4 and date.day == 28 then
|
||||
print("Ed Balls")
|
||||
else
|
||||
local tMotd = {}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
local capture = require "test_helpers".capture_program
|
||||
|
||||
describe("The motd program", function()
|
||||
local function setup_date(month, day)
|
||||
stub(os, "date", function() return { month = month, day = day } end)
|
||||
local function setup_date(day, month)
|
||||
stub(os, "date", function() return { day = day, month = month } end)
|
||||
end
|
||||
|
||||
it("displays MOTD", function()
|
||||
@ -16,20 +16,26 @@ describe("The motd program", function()
|
||||
:matches { ok = true, output = "Hello World!\n", error = "" }
|
||||
end)
|
||||
|
||||
it("displays date-specific MOTD (1/1)", function()
|
||||
it("displays date-specific MOTD (1 Jan)", function()
|
||||
setup_date(1, 1)
|
||||
expect(capture(stub, "motd"))
|
||||
:matches { ok = true, output = "Happy new year!\n", error = "" }
|
||||
end)
|
||||
|
||||
it("displays date-specific MOTD (10/31)", function()
|
||||
setup_date(10, 31)
|
||||
it("displays date-specific MOTD (28 Apr)", function()
|
||||
setup_date(28, 4)
|
||||
expect(capture(stub, "motd"))
|
||||
:matches { ok = true, output = "Ed Balls\n", error = "" }
|
||||
end)
|
||||
|
||||
it("displays date-specific MOTD (31 Oct)", function()
|
||||
setup_date(31, 10)
|
||||
expect(capture(stub, "motd"))
|
||||
:matches { ok = true, output = "OOoooOOOoooo! Spooky!\n", error = "" }
|
||||
end)
|
||||
|
||||
it("displays date-specific MOTD (12/24)", function()
|
||||
setup_date(12, 24)
|
||||
it("displays date-specific MOTD (24 Dec)", function()
|
||||
setup_date(24, 12)
|
||||
expect(capture(stub, "motd"))
|
||||
:matches { ok = true, output = "Merry X-mas!\n", error = "" }
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user