aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-08-10 21:29:48 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-08-10 21:30:44 +0100
commitd0f891ae0215d7963b3918f3847ee4c015a6b90c (patch)
tree5b6aa7805b00763763363ebcd11557061ebdb29b /activerecord
parentad28e0037b1d27494b846b1e65db874c37445e91 (diff)
downloadrails-d0f891ae0215d7963b3918f3847ee4c015a6b90c.tar.gz
rails-d0f891ae0215d7963b3918f3847ee4c015a6b90c.tar.bz2
rails-d0f891ae0215d7963b3918f3847ee4c015a6b90c.zip
Rewrite hm:t#create tests using assert_no_difference and assert_difference
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 59985374d3..a9d4d88148 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -180,27 +180,23 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
def test_associate_with_create_and_invalid_options
- peeps = companies(:first_firm).developers.count
- assert_nothing_raised { companies(:first_firm).developers.create(:name => '0') }
- assert_equal peeps, companies(:first_firm).developers.count
+ firm = companies(:first_firm)
+ assert_no_difference('firm.developers.count') { assert_nothing_raised { firm.developers.create(:name => '0') } }
end
def test_associate_with_create_and_valid_options
- peeps = companies(:first_firm).developers.count
- assert_nothing_raised { companies(:first_firm).developers.create(:name => 'developer') }
- assert_equal peeps + 1, companies(:first_firm).developers.count
+ firm = companies(:first_firm)
+ assert_difference('firm.developers.count', 1) { firm.developers.create(:name => 'developer') }
end
def test_associate_with_create_bang_and_invalid_options
- peeps = companies(:first_firm).developers.count
- assert_raises(ActiveRecord::RecordInvalid) { companies(:first_firm).developers.create!(:name => '0') }
- assert_equal peeps, companies(:first_firm).developers.count
+ firm = companies(:first_firm)
+ assert_no_difference('firm.developers.count') { assert_raises(ActiveRecord::RecordInvalid) { firm.developers.create!(:name => '0') } }
end
def test_associate_with_create_bang_and_valid_options
- peeps = companies(:first_firm).developers.count
- assert_nothing_raised { companies(:first_firm).developers.create!(:name => 'developer') }
- assert_equal peeps + 1, companies(:first_firm).developers.count
+ firm = companies(:first_firm)
+ assert_difference('firm.developers.count', 1) { firm.developers.create!(:name => 'developer') }
end
def test_clear_associations