forked from AstroNvim/user_example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrspec-docker.lua
45 lines (38 loc) · 990 Bytes
/
rspec-docker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local M ={}
local test_outputs = {}
local function extract_summary(outputs)
for _, line in ipairs(outputs) do
if line:match("%d+ examples?, %d+ failures?") then
return line
end
end
return "No summary found"
end
local function create_progress_window()
local message = "Running Rspec in Docker..."
end
function M.run_docker_rspec()
local rspec_runnig = true
local path = vim.fn.expand('%')
local cmd = "docker compose exec puma bundle exec rspec " .. path
vim.fn.jobstart(cmd, {
on_stdout = function(_, data)
if data then
for _, line in ipairs(data) do
if line ~= "" then
table.insert(test_outputs, line)
end
end
end
end,
stdout_buffered = true,
stderr_buffered = true,
on_exit = function()
local summary = extract_summary(test_outputs)
vim.api.nvim_echo({{summary, "None"}}, true, {})
test_outputs = {}
rspec_runnig = false
end
})
end
return M