local O=import("\046\047\084\101\115\116\083\101\114\118\105\099\101")describe("\105\110\115\116\097\110\099\101\115\046\084\101\115\116\083\101\114\118\105\099\101",function()it("\115\104\111\117\108\100 \105\110\115\116\097\110\116\105\097\116\101",function()local m=O:new()assert.not_nil(m)assert.not_nil(m.Error)end)it("\115\104\111\117\108\100 \119\114\105\116\101 \116\111 \115\116\100\101\114\114",function()local m=O:new()local d=io.stderr local k=spy.new(function(O,m) end)io.stderr={write=k}m:Error("\084\101\115\116\105\110\103 \116\101\115\116\115 \105\110 \097 \108\105\098\114\097\114\121 \102\111\114 \116\101\115\116\105\110\103\063");(assert.spy(k)).was_called_with(io.stderr,"\084\101\115\116\105\110\103 \116\101\115\116\115 \105\110 \097 \108\105\098\114\097\114\121 \102\111\114 \116\101\115\116\105\110\103\063")io.stderr=d end)end)
local TestService = import("./TestService")

describe("instances.TestService", function()
	it("should instantiate", function()
		local instance = TestService:new()

		assert.not_nil(instance)
		assert.not_nil(instance.Error)
	end)

	it("should write to stderr", function()
		local instance = TestService:new()
		local oldErr = io.stderr

		local writeSpy = spy.new(function(_, msg) end)

		io.stderr = { -- luacheck: ignore
			write = writeSpy
		}

		instance:Error("Testing tests in a library for testing?")

		assert.spy(writeSpy).was_called_with(io.stderr, "Testing tests in a library for testing?")

		io.stderr = oldErr -- luacheck: ignore
	end)
end)
