-
Notifications
You must be signed in to change notification settings - Fork 43
/
commandline_test.rb
executable file
·37 lines (29 loc) · 1.12 KB
/
commandline_test.rb
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
#! /usr/bin/env rspec
require_relative "test_helper"
Yast.import "CommandLine"
describe Yast::CommandLine do
# restore the original modes to not accidentally influence the other tests
# (these tests change the UI mode to "commandline")
around(:example) do |example|
orig_mode = Yast::Mode.mode
orig_ui = Yast::Mode.ui
example.run
Yast::Mode.SetMode(orig_mode)
Yast::Mode.SetUI(orig_ui)
end
before do
allow(Yast::Debugger).to receive(:installed?).and_return(false)
end
it "invokes initialize, handler and finish" do
expect(STDOUT).to receive(:puts).with("Initialize called").ordered
expect(STDOUT).to receive(:puts).with("something").ordered
expect(STDOUT).to receive(:puts).with("Finish called").ordered
Yast::WFM.CallFunction("dummy_cmdline", ["echo", "text=something"])
end
it "displays errors and aborts" do
expect(STDOUT).to receive(:puts).with("Initialize called").ordered
expect(Yast::CommandLine).to receive(:Print).with(/I crashed/).ordered
expect(STDOUT).to_not receive(:puts).with("Finish called")
Yast::WFM.CallFunction("dummy_cmdline", ["crash"])
end
end