2018-06-10 21:15:12 +00:00
|
|
|
require "../spec_helper"
|
|
|
|
|
|
|
|
module Ameba
|
|
|
|
describe Issue do
|
|
|
|
it "accepts rule and message" do
|
2021-10-25 22:09:39 +00:00
|
|
|
issue = Issue.new code: "",
|
|
|
|
rule: DummyRule.new,
|
2018-06-10 21:15:12 +00:00
|
|
|
location: nil,
|
|
|
|
end_location: nil,
|
|
|
|
message: "Blah",
|
|
|
|
status: nil
|
|
|
|
|
|
|
|
issue.rule.should_not be_nil
|
|
|
|
issue.message.should eq "Blah"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "accepts location" do
|
|
|
|
location = Crystal::Location.new("path", 3, 2)
|
2021-10-25 22:09:39 +00:00
|
|
|
issue = Issue.new code: "",
|
|
|
|
rule: DummyRule.new,
|
2018-06-10 21:15:12 +00:00
|
|
|
location: location,
|
|
|
|
end_location: nil,
|
|
|
|
message: "Blah",
|
|
|
|
status: nil
|
|
|
|
|
|
|
|
issue.location.to_s.should eq location.to_s
|
|
|
|
issue.end_location.should eq nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "accepts end_location" do
|
|
|
|
location = Crystal::Location.new("path", 3, 2)
|
2021-10-25 22:09:39 +00:00
|
|
|
issue = Issue.new code: "",
|
|
|
|
rule: DummyRule.new,
|
2018-06-10 21:15:12 +00:00
|
|
|
location: nil,
|
|
|
|
end_location: location,
|
|
|
|
message: "Blah",
|
|
|
|
status: nil
|
|
|
|
|
|
|
|
issue.location.should eq nil
|
|
|
|
issue.end_location.to_s.should eq location.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
it "accepts status" do
|
2021-10-25 22:09:39 +00:00
|
|
|
issue = Issue.new code: "",
|
|
|
|
rule: DummyRule.new,
|
2018-06-10 21:15:12 +00:00
|
|
|
location: nil,
|
|
|
|
end_location: nil,
|
|
|
|
message: "",
|
2021-01-26 06:38:19 +00:00
|
|
|
status: :disabled
|
2018-06-10 21:15:12 +00:00
|
|
|
|
2021-01-26 06:38:19 +00:00
|
|
|
issue.status.should eq Issue::Status::Disabled
|
|
|
|
issue.disabled?.should be_true
|
|
|
|
issue.enabled?.should be_false
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sets status to :enabled by default" do
|
2021-10-25 22:09:39 +00:00
|
|
|
issue = Issue.new code: "",
|
|
|
|
rule: DummyRule.new,
|
2021-01-26 06:38:19 +00:00
|
|
|
location: nil,
|
|
|
|
end_location: nil,
|
|
|
|
message: ""
|
|
|
|
|
|
|
|
issue.status.should eq Issue::Status::Enabled
|
|
|
|
issue.enabled?.should be_true
|
|
|
|
issue.disabled?.should be_false
|
2018-06-10 21:15:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|