Skip to content

Commit

Permalink
make fixture accessors private
Browse files Browse the repository at this point in the history
prevent to be run fixture accessor (e.g. test_foos for TestFoo model) as a test case

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
no6v authored and josevalim committed May 16, 2010
1 parent 3570f3e commit e535b45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions activerecord/lib/active_record/fixtures.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ def setup_fixture_accessors(table_names = nil)


instances.size == 1 ? instances.first : instances instances.size == 1 ? instances.first : instances
end end
private table_name
end end
end end


Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/fixtures_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ def test_fixtures_from_root_yml_without_instantiation
assert_nil @unknown assert_nil @unknown
end end


def test_visibility_of_accessor_method
assert_equal false, respond_to?(:topics, false), "should be private method"
assert_equal true, respond_to?(:topics, true), "confirm to respond surely"
end

def test_accessor_methods def test_accessor_methods
assert_equal "The First Topic", topics(:first).title assert_equal "The First Topic", topics(:first).title
assert_equal "Jamis", developers(:jamis).name assert_equal "Jamis", developers(:jamis).name
Expand Down

0 comments on commit e535b45

Please sign in to comment.