Are there any tools that’d indicate that your code can produce different results in different ruby versions?
I’m envisaging something like
a = 1
b = 2
string = [1, 2, 3, 4].to_s
ToolName: Array#to_s has different behaviour in Ruby 1.8 and 1.9
Or failing that, inspect each variable at each line and indicate the first point at which they diverge under different versions, such as:
Ruby1.8:
a: 1 at line 1
b: 2 at line 2
string: "1234" at line 3
Ruby1.9:
a: 1 at line 1
b: 2 at line 2
string: "[1, 2, 3, 4]" at line 3
Ruby1.8 and Ruby1.9 first differ at line 3
Or is the only approach currently available to unit test your code, and make sure the tests pass on all versions of ruby?
The gem One9 allows you to run a test suite, and it’ll report which methods you’ve called that have changed between 1.8 and 1.9.