4
class FinderRespondToTest < ActiveRecord::TestCase
8
def test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method
9
class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) { }
10
assert Topic.respond_to?(:method_added_for_finder_respond_to_test)
12
class << Topic; self; end.send(:remove_method, :method_added_for_finder_respond_to_test)
15
def test_should_preserve_normal_respond_to_behaviour_and_respond_to_standard_object_method
16
assert Topic.respond_to?(:to_s)
19
def test_should_respond_to_find_by_one_attribute_before_caching
20
ensure_topic_method_is_not_cached(:find_by_title)
21
assert Topic.respond_to?(:find_by_title)
24
def test_should_respond_to_find_all_by_one_attribute
25
ensure_topic_method_is_not_cached(:find_all_by_title)
26
assert Topic.respond_to?(:find_all_by_title)
29
def test_should_respond_to_find_all_by_two_attributes
30
ensure_topic_method_is_not_cached(:find_all_by_title_and_author_name)
31
assert Topic.respond_to?(:find_all_by_title_and_author_name)
34
def test_should_respond_to_find_by_two_attributes
35
ensure_topic_method_is_not_cached(:find_by_title_and_author_name)
36
assert Topic.respond_to?(:find_by_title_and_author_name)
39
def test_should_respond_to_find_or_initialize_from_one_attribute
40
ensure_topic_method_is_not_cached(:find_or_initialize_by_title)
41
assert Topic.respond_to?(:find_or_initialize_by_title)
44
def test_should_respond_to_find_or_initialize_from_two_attributes
45
ensure_topic_method_is_not_cached(:find_or_initialize_by_title_and_author_name)
46
assert Topic.respond_to?(:find_or_initialize_by_title_and_author_name)
49
def test_should_respond_to_find_or_create_from_one_attribute
50
ensure_topic_method_is_not_cached(:find_or_create_by_title)
51
assert Topic.respond_to?(:find_or_create_by_title)
54
def test_should_respond_to_find_or_create_from_two_attributes
55
ensure_topic_method_is_not_cached(:find_or_create_by_title_and_author_name)
56
assert Topic.respond_to?(:find_or_create_by_title_and_author_name)
59
def test_should_not_respond_to_find_by_one_missing_attribute
60
assert !Topic.respond_to?(:find_by_undertitle)
63
def test_should_not_respond_to_find_by_invalid_method_syntax
64
assert !Topic.respond_to?(:fail_to_find_by_title)
65
assert !Topic.respond_to?(:find_by_title?)
66
assert !Topic.respond_to?(:fail_to_find_or_create_by_title)
67
assert !Topic.respond_to?(:find_or_create_by_title?)
72
def ensure_topic_method_is_not_cached(method_id)
73
class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.any? { |m| m.to_s == method_id.to_s }
b'\\ No newline at end of file'