Skip to content

Commit

Permalink
test against ruby features in order to fix tests on Ruby 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove authored and arunagw committed Apr 12, 2012
1 parent e0fd4fc commit 96d81e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion activemodel/test/cases/attribute_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,24 @@ def foo
assert_raises(NoMethodError) { m.protected_method }
end

class ClassWithProtected
protected
def protected_method
end
end

test 'should not interfere with respond_to? if the attribute has a private/protected method' do
m = ModelWithAttributes2.new
m.attributes = { 'private_method' => '<3', 'protected_method' => 'O_o' }

assert !m.respond_to?(:private_method)
assert m.respond_to?(:private_method, true)

c = ClassWithProtected.new

# This is messed up, but it's how Ruby works at the moment. Apparently it will be changed
# in the future.
assert m.respond_to?(:protected_method)
assert_equal c.respond_to?(:protected_method), m.respond_to?(:protected_method)
assert m.respond_to?(:protected_method, true)
end

Expand Down

0 comments on commit 96d81e5

Please sign in to comment.