Skip to content

Commit d4e74b3

Browse files
committed
Add spec for issue documentation output
1 parent dddf880 commit d4e74b3

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

spec/cc/engine/issue_spec.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@ module CC::Engine
3232
expect(attributes["location"]["positions"]["end"]["line"]).to eq(10)
3333
expect(attributes["location"]["positions"]["begin"]["column"]).to eq(4)
3434
expect(attributes["location"]["positions"]["end"]["column"]).to eq(100)
35-
expect(attributes["content"]["body"].squish).to include(
36-
"This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum."
37-
)
35+
expect(attributes["content"]).to be_nil
36+
end
37+
38+
context "with documentation" do
39+
let(:offense) { super().tap { |offense| offense.cop_name = "Style/Alias" } }
40+
41+
it "includes the documentation in the returned json" do
42+
issue = Issue.new(offense, "app/models/user.rb")
43+
attributes = JSON.parse(issue.to_json)
44+
expect(attributes["content"]["body"].squish).to include(
45+
"This cop enforces the use of either `#alias` or `#alias_method` depending on configuration."
46+
)
47+
end
3848
end
3949
end
4050

0 commit comments

Comments
 (0)