Permalink
Browse files

Use instance_variable_defined? instead of instance_variables.include?…

… to account for string/symbol differences between 1.8 and 1.9

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d96e38b commit e36b9b95feae48d51aeed81f5348a7238138a716 @jeremy jeremy committed Sep 27, 2007
@@ -6,46 +6,46 @@ def setup
@instance = @target.new
end
- def test_attr_internal_reader
+ def test_reader
assert_nothing_raised { @target.attr_internal_reader :foo }
- assert !@instance.instance_variables.include?('@_foo')
+ assert !@instance.instance_variable_defined?('@_foo')
assert_raise(NoMethodError) { @instance.foo = 1 }
@instance.instance_variable_set('@_foo', 1)
assert_nothing_raised { assert_equal 1, @instance.foo }
end
- def test_attr_internal_writer
+ def test_writer
assert_nothing_raised { @target.attr_internal_writer :foo }
- assert !@instance.instance_variables.include?('@_foo')
+ assert !@instance.instance_variable_defined?('@_foo')
assert_nothing_raised { assert_equal 1, @instance.foo = 1 }
assert_equal 1, @instance.instance_variable_get('@_foo')
assert_raise(NoMethodError) { @instance.foo }
end
- def test_attr_internal_accessor
+ def test_accessor
assert_nothing_raised { @target.attr_internal :foo }
- assert !@instance.instance_variables.include?('@_foo')
+ assert !@instance.instance_variable_defined?('@_foo')
assert_nothing_raised { assert_equal 1, @instance.foo = 1 }
assert_equal 1, @instance.instance_variable_get('@_foo')
assert_nothing_raised { assert_equal 1, @instance.foo }
end
- def test_attr_internal_naming_format
+ def test_naming_format
assert_equal '@_%s', @target.attr_internal_naming_format
assert_nothing_raised { @target.attr_internal_naming_format = '@abc%sdef' }
@target.attr_internal :foo
- assert !@instance.instance_variables.include?('@_foo')
- assert !@instance.instance_variables.include?('@abcfoodef')
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert !@instance.instance_variable_defined?('@abcfoodef')
assert_nothing_raised { @instance.foo = 1 }
- assert !@instance.instance_variables.include?('@_foo')
- assert @instance.instance_variables.include?('@abcfoodef')
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert @instance.instance_variable_defined?('@abcfoodef')
ensure
@target.attr_internal_naming_format = '@_%s'
end

0 comments on commit e36b9b9

Please sign in to comment.