Skip to content

Commit ce0e4fe

Browse files
joelhawksleyCopilot
andcommitted
Replace stubbed RDoc tests with version-gated tests
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d
1 parent 4c28d17 commit ce0e4fe

2 files changed

Lines changed: 12 additions & 29 deletions

File tree

‎lib/github/markup/rdoc.rb‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ def initialize
1111

1212
def render(filename, content, options: {})
1313
# RDoc 4-7 require positional Options; RDoc 8 uses keyword options.
14+
# Each run covers only the installed RDoc's branch; CI tests both.
15+
# :nocov:
1416
if (4...8).cover?(::RDoc::VERSION.to_i)
1517
h = ::RDoc::Markup::ToHtml.new(::RDoc::Options.new)
1618
else
1719
h = ::RDoc::Markup::ToHtml.new
1820
end
21+
# :nocov:
1922
h.convert(content)
2023
end
2124

‎test/coverage_test.rb‎

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,37 +95,17 @@ def test_try_require_returns_false_for_missing_gem
9595
end
9696

9797
# --- rdoc.rb formatter constructor compatibility -----------------------
98+
# Only the tests matching the installed RDoc are defined; CI runs both.
9899

99-
def test_rdoc_4_through_7_receive_options
100-
formatter = Class.new do
101-
def initialize(options)
102-
raise ArgumentError, "expected RDoc::Options" unless options.is_a?(::RDoc::Options)
103-
end
104-
105-
def convert(content); "rendered:#{content}"; end
106-
end
107-
108-
["4.0.0", "6.3.4.1", "7.2.0"].each do |version|
109-
with_stub_const("RDoc::VERSION", version) do
110-
with_stub_const("RDoc::Markup::ToHtml", formatter) do
111-
assert_equal "rendered:hello", GitHub::Markup::RDoc.new.render("README.rdoc", "hello")
112-
end
113-
end
100+
if ::RDoc::VERSION.to_i >= 8
101+
def test_rdoc_8_formatter_rejects_positional_options
102+
assert_raises(ArgumentError) { ::RDoc::Markup::ToHtml.new(::RDoc::Options.new) }
103+
assert_includes GitHub::Markup::RDoc.new.render("README.rdoc", "*bold*"), "<strong>bold</strong>"
114104
end
115-
end
116-
117-
def test_rdoc_8_and_legacy_versions_receive_no_positional_options
118-
formatter = Class.new do
119-
def initialize; end
120-
def convert(content); "rendered:#{content}"; end
121-
end
122-
123-
["3.6.1", "8.0.0", "8.1.0"].each do |version|
124-
with_stub_const("RDoc::VERSION", version) do
125-
with_stub_const("RDoc::Markup::ToHtml", formatter) do
126-
assert_equal "rendered:hello", GitHub::Markup::RDoc.new.render("README.rdoc", "hello")
127-
end
128-
end
105+
else
106+
def test_rdoc_7_formatter_requires_positional_options
107+
assert_raises(ArgumentError) { ::RDoc::Markup::ToHtml.new }
108+
assert_includes GitHub::Markup::RDoc.new.render("README.rdoc", "*bold*"), "<strong>bold</strong>"
129109
end
130110
end
131111

0 commit comments

Comments
 (0)