class FinderRespondToTest
Public Instance Methods
test_should_not_respond_to_find_by_invalid_method_syntax()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 49 def test_should_not_respond_to_find_by_invalid_method_syntax assert !Topic.respond_to?(:fail_to_find_by_title) assert !Topic.respond_to?(:find_by_title?) assert !Topic.respond_to?(:fail_to_find_or_create_by_title) assert !Topic.respond_to?(:find_or_create_by_title?) end
test_should_not_respond_to_find_by_one_missing_attribute()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 45 def test_should_not_respond_to_find_by_one_missing_attribute assert !Topic.respond_to?(:find_by_undertitle) end
test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 14 def test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) {} assert_respond_to Topic, :method_added_for_finder_respond_to_test ensure class << Topic; self; end.send(:remove_method, :method_added_for_finder_respond_to_test) end
test_should_preserve_normal_respond_to_behaviour_and_respond_to_standard_object_method()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 21 def test_should_preserve_normal_respond_to_behaviour_and_respond_to_standard_object_method assert_respond_to Topic, :to_s end
test_should_preserve_normal_respond_to_behaviour_on_base()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 9 def test_should_preserve_normal_respond_to_behaviour_on_base assert_respond_to ActiveRecord::Base, :new assert !ActiveRecord::Base.respond_to?(:find_by_something) end
test_should_respond_to_find_all_by_an_aliased_attribute()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 40 def test_should_respond_to_find_all_by_an_aliased_attribute ensure_topic_method_is_not_cached(:find_by_heading) assert_respond_to Topic, :find_by_heading end
test_should_respond_to_find_by_one_attribute_before_caching()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 25 def test_should_respond_to_find_by_one_attribute_before_caching ensure_topic_method_is_not_cached(:find_by_title) assert_respond_to Topic, :find_by_title end
test_should_respond_to_find_by_two_attributes()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 35 def test_should_respond_to_find_by_two_attributes ensure_topic_method_is_not_cached(:find_by_title_and_author_name) assert_respond_to Topic, :find_by_title_and_author_name end
test_should_respond_to_find_by_with_bang()
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 30 def test_should_respond_to_find_by_with_bang ensure_topic_method_is_not_cached(:find_by_title!) assert_respond_to Topic, :find_by_title! end
Private Instance Methods
ensure_topic_method_is_not_cached(method_id)
click to toggle source
# File activerecord/test/cases/finder_respond_to_test.rb, line 58 def ensure_topic_method_is_not_cached(method_id) class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.include? method_id end