Skip to content

Instantly share code, notes, and snippets.

@guillermo
Created July 17, 2012 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillermo/3131665 to your computer and use it in GitHub Desktop.
Save guillermo/3131665 to your computer and use it in GitHub Desktop.
OpenStruct id method
$ cat test/test_id_method.rb
require 'test/unit'
require 'ostruct'
print "\n", RUBY_VERSION, "\n"
class TestIdMethod < Test::Unit::TestCase
def test_id_method
obj1 = OpenStruct.new
obj1.id = 3
assert_equal obj1.id, 3, "should be equal"
end
end
$ rvm 1.8.6,system,1.9.2,1.9.3 do ruby test/test_id_method.rb
1.8.6
Loaded suite test/test_id_method
Started
test/test_id_method.rb:12: warning: Object#id will be deprecated; use Object#object_id
F
Finished in 0.005514 seconds.
1) Failure:
test_id_method(TestIdMethod) [test/test_id_method.rb:12]:
should be equal.
<2278333300> expected but was
<3>.
1 tests, 1 assertions, 1 failures, 0 errors
1.8.7
Loaded suite test/test_id_method
Started
test/test_id_method.rb:12: warning: Object#id will be deprecated; use Object#object_id
F
Finished in 0.004484 seconds.
1) Failure:
test_id_method(TestIdMethod) [test/test_id_method.rb:12]:
should be equal.
<2250012820> expected but was
<3>.
1 tests, 1 assertions, 1 failures, 0 errors
1.9.2
Loaded suite test/test_id_method
Started
.
Finished in 0.000446 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 13364
1.9.2
Loaded suite test/test_id_method
Started
.
Finished in 0.000416 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 26480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment