-
Notifications
You must be signed in to change notification settings - Fork 43
/
issue_test.rb
executable file
·79 lines (68 loc) · 2.26 KB
/
issue_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env rspec
# Copyright (c) [2021] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.
require_relative "../test_helper"
require "y2issues"
describe Y2Issues::Issue do
describe "#new" do
subject(:issue) do
described_class.new(
"Something went wrong",
location: Y2Issues::Location.parse("file:/etc/hosts"),
severity: :fatal
)
end
it "creates an issue" do
expect(issue.message).to eq("Something went wrong")
expect(issue.location).to eq(Y2Issues::Location.parse("file:/etc/hosts"))
expect(issue.severity).to eq(:fatal)
end
context "when location is given as a string" do
subject(:issue) do
described_class.new(
"Something went wrong",
location: "file:/etc/hosts"
)
end
it "parses the given location" do
expect(issue.location).to eq(Y2Issues::Location.parse("file:/etc/hosts"))
end
end
context "when a severity is not given" do
subject(:issue) { described_class.new("Something went wrong") }
it "sets the severity to :warn" do
expect(issue.severity).to eq(:warn)
end
end
end
describe "#fatal?" do
context "when severity is :fatal" do
subject(:issue) { described_class.new("Something went wrong", severity: :fatal) }
it "returns true" do
expect(issue.fatal?).to eq(true)
end
end
context "when severity is :fatal" do
subject(:issue) { described_class.new("Something went wrong", severity: :warn) }
it "returns false" do
expect(issue.fatal?).to eq(false)
end
end
end
end