diff options
author | Takehiro Adachi <takehiro0740@gmail.com> | 2013-05-22 02:19:50 +0900 |
---|---|---|
committer | Takehiro Adachi <takehiro0740@gmail.com> | 2013-05-22 02:24:37 +0900 |
commit | 24f0099ec3360972ed74c55ec3703c87d2a31d17 (patch) | |
tree | 4bcd2d0e8b690513e383d4538f48b216be72f2c0 | |
parent | bff89a2022aedec60929f6d6744eefc84a5c102a (diff) | |
download | rails-24f0099ec3360972ed74c55ec3703c87d2a31d17.tar.gz rails-24f0099ec3360972ed74c55ec3703c87d2a31d17.tar.bz2 rails-24f0099ec3360972ed74c55ec3703c87d2a31d17.zip |
Extract AR::Core#inspect and AR::Core.inspect's test code from base_test.rb
The methods got moved to core.rb in commit
b2c9ce341a1c907041f55461aefebb0321280cb5, but the tests never did.
-rw-r--r-- | activerecord/test/cases/base_test.rb | 24 | ||||
-rw-r--r-- | activerecord/test/cases/core_test.rb | 33 |
2 files changed, 33 insertions, 24 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 15d536daf5..b8ade90aa2 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1228,30 +1228,6 @@ class BasicsTest < ActiveRecord::TestCase assert_no_queries { assert true } end - def test_inspect_class - assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect - assert_equal 'LoosePerson(abstract)', LoosePerson.inspect - assert_match(/^Topic\(id: integer, title: string/, Topic.inspect) - end - - def test_inspect_instance - topic = topics(:first) - assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", important: nil, approved: false, replies_count: 1, unique_replies_count: 0, parent_id: nil, parent_title: nil, type: nil, group: nil, created_at: "#{topic.created_at.to_s(:db)}", updated_at: "#{topic.updated_at.to_s(:db)}">), topic.inspect - end - - def test_inspect_new_instance - assert_match(/Topic id: nil/, Topic.new.inspect) - end - - def test_inspect_limited_select_instance - assert_equal %(#<Topic id: 1>), Topic.all.merge!(:select => 'id', :where => 'id = 1').first.inspect - assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.all.merge!(:select => 'id, title', :where => 'id = 1').first.inspect - end - - def test_inspect_class_without_table - assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect - end - def test_attribute_for_inspect t = topics(:first) t.title = "The First Topic Now Has A Title With\nNewlines And More Than 50 Characters" diff --git a/activerecord/test/cases/core_test.rb b/activerecord/test/cases/core_test.rb new file mode 100644 index 0000000000..2a52bf574c --- /dev/null +++ b/activerecord/test/cases/core_test.rb @@ -0,0 +1,33 @@ +require 'cases/helper' +require 'models/person' +require 'models/topic' + +class NonExistentTable < ActiveRecord::Base; end + +class CoreTest < ActiveRecord::TestCase + fixtures :topics + + def test_inspect_class + assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect + assert_equal 'LoosePerson(abstract)', LoosePerson.inspect + assert_match(/^Topic\(id: integer, title: string/, Topic.inspect) + end + + def test_inspect_instance + topic = topics(:first) + assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", important: nil, approved: false, replies_count: 1, unique_replies_count: 0, parent_id: nil, parent_title: nil, type: nil, group: nil, created_at: "#{topic.created_at.to_s(:db)}", updated_at: "#{topic.updated_at.to_s(:db)}">), topic.inspect + end + + def test_inspect_new_instance + assert_match(/Topic id: nil/, Topic.new.inspect) + end + + def test_inspect_limited_select_instance + assert_equal %(#<Topic id: 1>), Topic.all.merge!(:select => 'id', :where => 'id = 1').first.inspect + assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.all.merge!(:select => 'id, title', :where => 'id = 1').first.inspect + end + + def test_inspect_class_without_table + assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect + end +end |