From 0400a7ff574f83f2f5d5c3f7d7569bfb37963dda Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 20 Apr 2013 09:26:07 +0200 Subject: if singletons belong to the contract, test them Object#respond_to? returns singletons and thus we inherit that contract. The implementation of the predicate is good, but the test is only checking boolean semantics, which in this case is not enough. --- activerecord/test/cases/relation_test.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 06723b9d7f..482c1b3d48 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -186,8 +186,11 @@ module ActiveRecord end def test_respond_to_for_non_selected_element + post = Post.select(:title).first + assert_equal false, post.respond_to?(:body), "post should not respond_to?(:body) since invoking it raises exception" + post = Post.select("'title' as post_title").first - assert !post.respond_to?(:body), "post should not respond_to?(:body) since invoking it raises exception" + assert_equal false, post.respond_to?(:title), "post should not respond_to?(:body) since invoking it raises exception" end end -- cgit v1.2.3