Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit abdcf65

Browse files
committed
fix problem in force_encoding in tests
force_encoding doesn't exist in ruby 1.8. Pass string as is in 1.8 and only force_encoding if string responds to it
1 parent a647c12 commit abdcf65

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/test_linkparse.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def test_linkparse
8484
assert(false, "datafile parsing error: bad header #{h}")
8585
end
8686
}
87-
88-
links = OpenID::parse_link_attrs(html.force_encoding('UTF-8'))
87+
html = html.force_encoding('UTF-8') if html.respond_to? :force_encoding
88+
links = OpenID::parse_link_attrs(html)
8989

9090
found = links.dup
9191
expected = expected_links.dup
@@ -100,7 +100,8 @@ def test_linkparse
100100
assert_equal(numtests, testnum, "Number of tests")
101101

102102
# test handling of invalid UTF-8 byte sequences
103-
html = "<html><body>hello joel\255</body></html>".force_encoding("UTF-8")
103+
html = "<html><body>hello joel\255</body></html>"
104+
html = html.force_encoding('UTF-8') if html.respond_to? :force_encoding
104105
assert_nothing_raised do
105106
OpenID::parse_link_attrs(html)
106107
end

0 commit comments

Comments
 (0)