aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-08 13:11:58 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-08 13:11:58 -0700
commit1c36172c13fc51b22167f5e8fc41b1da9f8fcb2a (patch)
treeeff2254dd84c81dda6db52b30286a2b5ad2cb525 /activerecord/test
parent0c407891fb209a4f94f09681db28e40a8b754198 (diff)
downloadrails-1c36172c13fc51b22167f5e8fc41b1da9f8fcb2a.tar.gz
rails-1c36172c13fc51b22167f5e8fc41b1da9f8fcb2a.tar.bz2
rails-1c36172c13fc51b22167f5e8fc41b1da9f8fcb2a.zip
Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.
[#1617 state:resolved]
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb4
-rw-r--r--activerecord/test/cases/associations/eager_test.rb8
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb26
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb10
-rw-r--r--activerecord/test/cases/associations/has_one_through_associations_test.rb4
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb2
-rwxr-xr-xactiverecord/test/cases/base_test.rb18
-rw-r--r--activerecord/test/cases/calculations_test.rb4
-rw-r--r--activerecord/test/cases/callbacks_test.rb4
-rw-r--r--activerecord/test/cases/dirty_test.rb2
-rw-r--r--activerecord/test/cases/finder_test.rb64
-rw-r--r--activerecord/test/cases/fixtures_test.rb4
-rw-r--r--activerecord/test/cases/inheritance_test.rb4
-rw-r--r--activerecord/test/cases/locking_test.rb10
-rw-r--r--activerecord/test/cases/migration_test.rb26
-rw-r--r--activerecord/test/cases/transactions_test.rb4
-rw-r--r--activerecord/test/cases/validations_test.rb12
18 files changed, 104 insertions, 104 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index 78b90121b4..ff3e54712e 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -318,8 +318,8 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
end
def test_belongs_to_proxy_should_not_respond_to_private_methods
- assert_raises(NoMethodError) { companies(:first_firm).private_method }
- assert_raises(NoMethodError) { companies(:second_client).firm.private_method }
+ assert_raise(NoMethodError) { companies(:first_firm).private_method }
+ assert_raise(NoMethodError) { companies(:second_client).firm.private_method }
end
def test_belongs_to_proxy_should_respond_to_private_methods_via_send
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 14099d4176..40723814c5 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -549,16 +549,16 @@ class EagerAssociationTest < ActiveRecord::TestCase
end
def test_eager_with_invalid_association_reference
- assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") {
+ assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") {
post = Post.find(6, :include=> :monkeys )
}
- assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") {
+ assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") {
post = Post.find(6, :include=>[ :monkeys ])
}
- assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") {
+ assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") {
post = Post.find(6, :include=>[ 'monkeys' ])
}
- assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys, :elephants") {
+ assert_raise(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys, :elephants") {
post = Post.find(6, :include=>[ :monkeys, :elephants ])
}
end
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 9f5f34306d..ca1772d1ca 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -616,7 +616,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
def test_updating_attributes_on_rich_associations
david = projects(:action_controller).developers.first
david.name = "DHH"
- assert_raises(ActiveRecord::ReadOnlyRecord) { david.save! }
+ assert_raise(ActiveRecord::ReadOnlyRecord) { david.save! }
end
def test_updating_attributes_on_rich_associations_with_limited_find_from_reflection
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 5efbc5bd0c..3f33baf88c 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -176,7 +176,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
def test_find_ids
firm = Firm.find(:first)
- assert_raises(ActiveRecord::RecordNotFound) { firm.clients.find }
+ assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find }
client = firm.clients.find(2)
assert_kind_of Client, client
@@ -190,7 +190,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal 2, client_ary.size
assert_equal client, client_ary.first
- assert_raises(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) }
+ assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) }
end
def test_find_string_ids_when_using_finder_sql
@@ -238,7 +238,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
def test_find_in_collection
assert_equal Client.find(2).name, companies(:first_firm).clients.find(2).name
- assert_raises(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) }
+ assert_raise(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) }
end
def test_find_grouped
@@ -278,36 +278,36 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
end
def test_create_with_bang_on_has_many_when_parent_is_new_raises
- assert_raises(ActiveRecord::RecordNotSaved) do
+ assert_raise(ActiveRecord::RecordNotSaved) do
firm = Firm.new
firm.plain_clients.create! :name=>"Whoever"
end
end
def test_regular_create_on_has_many_when_parent_is_new_raises
- assert_raises(ActiveRecord::RecordNotSaved) do
+ assert_raise(ActiveRecord::RecordNotSaved) do
firm = Firm.new
firm.plain_clients.create :name=>"Whoever"
end
end
def test_create_with_bang_on_has_many_raises_when_record_not_saved
- assert_raises(ActiveRecord::RecordInvalid) do
+ assert_raise(ActiveRecord::RecordInvalid) do
firm = Firm.find(:first)
firm.plain_clients.create!
end
end
def test_create_with_bang_on_habtm_when_parent_is_new_raises
- assert_raises(ActiveRecord::RecordNotSaved) do
+ assert_raise(ActiveRecord::RecordNotSaved) do
Developer.new("name" => "Aredridel").projects.create!
end
end
def test_adding_a_mismatch_class
- assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil }
- assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << 1 }
- assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << Topic.find(1) }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << 1 }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << Topic.find(1) }
end
def test_adding_a_collection
@@ -602,7 +602,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
end
def test_invalid_belongs_to_dependent_option_raises_exception
- assert_raises ArgumentError do
+ assert_raise ArgumentError do
Author.belongs_to :special_author_address, :dependent => :nullify
end
end
@@ -628,13 +628,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
def test_deleting_type_mismatch
david = Developer.find(1)
david.projects.reload
- assert_raises(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) }
end
def test_deleting_self_type_mismatch
david = Developer.find(1)
david.projects.reload
- assert_raises(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) }
end
def test_destroy_all
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index 0aafbcee36..4947f1543c 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -59,8 +59,8 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
end
def test_type_mismatch
- assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = 1 }
- assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = Project.find(1) }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = 1 }
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).account = Project.find(1) }
end
def test_natural_assignment
@@ -76,7 +76,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
companies(:first_firm).save
assert_nil companies(:first_firm).account
# account is dependent, therefore is destroyed when reference to owner is lost
- assert_raises(ActiveRecord::RecordNotFound) { Account.find(old_account_id) }
+ assert_raise(ActiveRecord::RecordNotFound) { Account.find(old_account_id) }
end
def test_nullification_on_association_change
@@ -281,8 +281,8 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
end
def test_has_one_proxy_should_not_respond_to_private_methods
- assert_raises(NoMethodError) { accounts(:signals37).private_method }
- assert_raises(NoMethodError) { companies(:first_firm).account.private_method }
+ assert_raise(NoMethodError) { accounts(:signals37).private_method }
+ assert_raise(NoMethodError) { companies(:first_firm).account.private_method }
end
def test_has_one_proxy_should_respond_to_private_methods_via_send
diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb
index f65d76e2ce..f96b55513e 100644
--- a/activerecord/test/cases/associations/has_one_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb
@@ -115,8 +115,8 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
end
def test_has_one_through_proxy_should_not_respond_to_private_methods
- assert_raises(NoMethodError) { clubs(:moustache_club).private_method }
- assert_raises(NoMethodError) { @member.club.private_method }
+ assert_raise(NoMethodError) { clubs(:moustache_club).private_method }
+ assert_raise(NoMethodError) { @member.club.private_method }
end
def test_has_one_through_proxy_should_respond_to_private_methods_via_send
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 759f9f3872..17ed302465 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -100,7 +100,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
%w(save create_or_update).each do |method|
klass = Class.new ActiveRecord::Base
klass.class_eval "def #{method}() 'defined #{method}' end"
- assert_raises ActiveRecord::DangerousAttributeError do
+ assert_raise ActiveRecord::DangerousAttributeError do
klass.instance_method_already_implemented?(method)
end
end
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index eacf4e7699..748a64af5e 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -424,8 +424,8 @@ class BasicsTest < ActiveRecord::TestCase
def test_non_attribute_access_and_assignment
topic = Topic.new
assert !topic.respond_to?("mumbo")
- assert_raises(NoMethodError) { topic.mumbo }
- assert_raises(NoMethodError) { topic.mumbo = 5 }
+ assert_raise(NoMethodError) { topic.mumbo }
+ assert_raise(NoMethodError) { topic.mumbo = 5 }
end
def test_preserving_date_objects
@@ -490,7 +490,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_record_not_found_exception
- assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
+ assert_raise(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
end
def test_initialize_with_attributes
@@ -848,7 +848,7 @@ class BasicsTest < ActiveRecord::TestCase
client.delete
assert client.frozen?
assert_kind_of Firm, client.firm
- assert_raises(ActiveSupport::FrozenObjectError) { client.name = "something else" }
+ assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" }
end
def test_destroy_new_record
@@ -862,7 +862,7 @@ class BasicsTest < ActiveRecord::TestCase
client.destroy
assert client.frozen?
assert_kind_of Firm, client.firm
- assert_raises(ActiveSupport::FrozenObjectError) { client.name = "something else" }
+ assert_raise(ActiveSupport::FrozenObjectError) { client.name = "something else" }
end
def test_update_attribute
@@ -910,8 +910,8 @@ class BasicsTest < ActiveRecord::TestCase
def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used
topic = TopicWithProtectedContentAndAccessibleAuthorName.new
- assert_raises(RuntimeError) { topic.attributes = { "author_name" => "me" } }
- assert_raises(RuntimeError) { topic.attributes = { "content" => "stuff" } }
+ assert_raise(RuntimeError) { topic.attributes = { "author_name" => "me" } }
+ assert_raise(RuntimeError) { topic.attributes = { "content" => "stuff" } }
end
def test_mass_assignment_protection
@@ -949,7 +949,7 @@ class BasicsTest < ActiveRecord::TestCase
def test_mass_assigning_invalid_attribute
firm = Firm.new
- assert_raises(ActiveRecord::UnknownAttributeError) do
+ assert_raise(ActiveRecord::UnknownAttributeError) do
firm.attributes = { "id" => 5, "type" => "Client", "i_dont_even_exist" => 20 }
end
end
@@ -1402,7 +1402,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_sql_injection_via_find
- assert_raises(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do
+ assert_raise(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do
Topic.find("123456 OR id > 0")
end
end
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index f01ac2ea39..56dcdea110 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -255,8 +255,8 @@ class CalculationsTest < ActiveRecord::TestCase
Company.send(:validate_calculation_options, :count, :include => true)
end
- assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) }
- assert_raises(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) }
+ assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :sum, :foo => :bar) }
+ assert_raise(ArgumentError) { Company.send(:validate_calculation_options, :count, :foo => :bar) }
end
def test_should_count_selected_field_with_include
diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb
index 33b1ea034d..95fddaeef6 100644
--- a/activerecord/test/cases/callbacks_test.rb
+++ b/activerecord/test/cases/callbacks_test.rb
@@ -352,13 +352,13 @@ class CallbacksTest < ActiveRecord::TestCase
david = ImmutableDeveloper.find(1)
assert david.valid?
assert !david.save
- assert_raises(ActiveRecord::RecordNotSaved) { david.save! }
+ assert_raise(ActiveRecord::RecordNotSaved) { david.save! }
david = ImmutableDeveloper.find(1)
david.salary = 10_000_000
assert !david.valid?
assert !david.save
- assert_raises(ActiveRecord::RecordInvalid) { david.save! }
+ assert_raise(ActiveRecord::RecordInvalid) { david.save! }
someone = CallbackCancellationDeveloper.find(1)
someone.cancel_before_save = true
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 5f5707b388..ac95bac4ad 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -228,7 +228,7 @@ class DirtyTest < ActiveRecord::TestCase
pirate = Pirate.new
pirate.parrot_id = 1
- assert_raises(ActiveRecord::RecordInvalid) { pirate.save! }
+ assert_raise(ActiveRecord::RecordInvalid) { pirate.save! }
check_pirate_after_save_failure(pirate)
end
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 375b9a849c..d8778957c0 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -146,7 +146,7 @@ class FinderTest < ActiveRecord::TestCase
end
def test_find_by_ids_missing_one
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, 2, 45) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, 2, 45) }
end
def test_find_all_with_limit
@@ -236,7 +236,7 @@ class FinderTest < ActiveRecord::TestCase
end
def test_unexisting_record_exception_handling
- assert_raises(ActiveRecord::RecordNotFound) {
+ assert_raise(ActiveRecord::RecordNotFound) {
Topic.find(1).parent
}
@@ -245,7 +245,7 @@ class FinderTest < ActiveRecord::TestCase
def test_find_only_some_columns
topic = Topic.find(1, :select => "author_name")
- assert_raises(ActiveRecord::MissingAttributeError) {topic.title}
+ assert_raise(ActiveRecord::MissingAttributeError) {topic.title}
assert_equal "David", topic.author_name
assert !topic.attribute_present?("title")
#assert !topic.respond_to?("title")
@@ -267,22 +267,22 @@ class FinderTest < ActiveRecord::TestCase
def test_find_on_array_conditions
assert Topic.find(1, :conditions => ["approved = ?", false])
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) }
end
def test_find_on_hash_conditions
assert Topic.find(1, :conditions => { :approved => false })
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :approved => true }) }
end
def test_find_on_hash_conditions_with_explicit_table_name
assert Topic.find(1, :conditions => { 'topics.approved' => false })
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { 'topics.approved' => true }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { 'topics.approved' => true }) }
end
def test_find_on_hash_conditions_with_hashed_table_name
assert Topic.find(1, :conditions => {:topics => { :approved => false }})
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => {:topics => { :approved => true }}) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => {:topics => { :approved => true }}) }
end
def test_find_with_hash_conditions_on_joined_table
@@ -300,7 +300,7 @@ class FinderTest < ActiveRecord::TestCase
def test_find_on_hash_conditions_with_explicit_table_name_and_aggregate
david = customers(:david)
assert Customer.find(david.id, :conditions => { 'customers.name' => david.name, :address => david.address })
- assert_raises(ActiveRecord::RecordNotFound) {
+ assert_raise(ActiveRecord::RecordNotFound) {
Customer.find(david.id, :conditions => { 'customers.name' => david.name + "1", :address => david.address })
}
end
@@ -311,13 +311,13 @@ class FinderTest < ActiveRecord::TestCase
def test_find_on_hash_conditions_with_range
assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1..2 }).map(&:id).sort
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :id => 2..3 }) }
end
def test_find_on_hash_conditions_with_end_exclusive_range
assert_equal [1,2,3], Topic.find(:all, :conditions => { :id => 1..3 }).map(&:id).sort
assert_equal [1,2], Topic.find(:all, :conditions => { :id => 1...3 }).map(&:id).sort
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(3, :conditions => { :id => 2...3 }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(3, :conditions => { :id => 2...3 }) }
end
def test_find_on_hash_conditions_with_multiple_ranges
@@ -327,9 +327,9 @@ class FinderTest < ActiveRecord::TestCase
def test_find_on_multiple_hash_conditions
assert Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => false })
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) }
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "HHC", :replies_count => 1, :approved => false }) }
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "HHC", :replies_count => 1, :approved => false }) }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => { :author_name => "David", :title => "The First Topic", :replies_count => 1, :approved => true }) }
end
def test_condition_interpolation
@@ -353,7 +353,7 @@ class FinderTest < ActiveRecord::TestCase
end
def test_hash_condition_find_malformed
- assert_raises(ActiveRecord::StatementInvalid) {
+ assert_raise(ActiveRecord::StatementInvalid) {
Company.find(:first, :conditions => { :id => 2, :dhh => true })
}
end
@@ -422,10 +422,10 @@ class FinderTest < ActiveRecord::TestCase
assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!"])
assert_nil Company.find(:first, :conditions => ["name = ?", "37signals!' OR 1=1"])
assert_kind_of Time, Topic.find(:first, :conditions => ["id = ?", 1]).written_on
- assert_raises(ActiveRecord::PreparedStatementInvalid) {
+ assert_raise(ActiveRecord::PreparedStatementInvalid) {
Company.find(:first, :conditions => ["id=? AND name = ?", 2])
}
- assert_raises(ActiveRecord::PreparedStatementInvalid) {
+ assert_raise(ActiveRecord::PreparedStatementInvalid) {
Company.find(:first, :conditions => ["id=?", 2, 3, 4])
}
end
@@ -442,11 +442,11 @@ class FinderTest < ActiveRecord::TestCase
def test_bind_arity
assert_nothing_raised { bind '' }
- assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '', 1 }
+ assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '', 1 }
- assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '?' }
+ assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?' }
assert_nothing_raised { bind '?', 1 }
- assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 }
+ assert_raise(ActiveRecord::PreparedStatementInvalid) { bind '?', 1, 1 }
end
def test_named_bind_variables
@@ -551,7 +551,7 @@ class FinderTest < ActiveRecord::TestCase
def test_find_by_one_attribute_bang
assert_equal topics(:first), Topic.find_by_title!("The First Topic")
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") }
+ assert_raise(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") }
end
def test_find_by_one_attribute_caches_dynamic_finder
@@ -632,14 +632,14 @@ class FinderTest < ActiveRecord::TestCase
end
def test_find_by_one_missing_attribute
- assert_raises(NoMethodError) { Topic.find_by_undertitle("The First Topic!") }
+ assert_raise(NoMethodError) { Topic.find_by_undertitle("The First Topic!") }
end
def test_find_by_invalid_method_syntax
- assert_raises(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") }
- assert_raises(NoMethodError) { Topic.find_by_title?("The First Topic") }
- assert_raises(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") }
- assert_raises(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") }
+ assert_raise(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") }
+ assert_raise(NoMethodError) { Topic.find_by_title?("The First Topic") }
+ assert_raise(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") }
+ assert_raise(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") }
end
def test_find_by_two_attributes
@@ -661,8 +661,8 @@ class FinderTest < ActiveRecord::TestCase
end
def test_find_last_by_invalid_method_syntax
- assert_raises(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") }
- assert_raises(NoMethodError) { Topic.find_last_by_title?("The First Topic") }
+ assert_raise(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") }
+ assert_raise(NoMethodError) { Topic.find_last_by_title?("The First Topic") }
end
def test_find_last_by_one_attribute_with_several_options
@@ -670,7 +670,7 @@ class FinderTest < ActiveRecord::TestCase
end
def test_find_last_by_one_missing_attribute
- assert_raises(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") }
+ assert_raise(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") }
end
def test_find_last_by_two_attributes
@@ -923,16 +923,16 @@ class FinderTest < ActiveRecord::TestCase
end
def test_find_with_bad_sql
- assert_raises(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" }
+ assert_raise(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" }
end
def test_find_with_invalid_params
- assert_raises(ArgumentError) { Topic.find :first, :join => "It should be `joins'" }
- assert_raises(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" }
+ assert_raise(ArgumentError) { Topic.find :first, :join => "It should be `joins'" }
+ assert_raise(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" }
end
def test_dynamic_finder_with_invalid_params
- assert_raises(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" }
+ assert_raise(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" }
end
def test_find_all_with_limit
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index eb63fd5f34..252bf4ff61 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -151,7 +151,7 @@ class FixturesTest < ActiveRecord::TestCase
end
def test_dirty_dirty_yaml_file
- assert_raises(Fixture::FormatError) do
+ assert_raise(Fixture::FormatError) do
Fixtures.new( Account.connection, "courses", 'Course', FIXTURES_ROOT + "/naked/yml/courses")
end
end
@@ -420,7 +420,7 @@ class InvalidTableNameFixturesTest < ActiveRecord::TestCase
self.use_transactional_fixtures = false
def test_raises_error
- assert_raises FixtureClassNotFound do
+ assert_raise FixtureClassNotFound do
funny_jokes(:a_joke)
end
end
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb
index 3f59eb9706..eae5a60829 100644
--- a/activerecord/test/cases/inheritance_test.rb
+++ b/activerecord/test/cases/inheritance_test.rb
@@ -68,7 +68,7 @@ class InheritanceTest < ActiveRecord::TestCase
if current_adapter?(:SybaseAdapter)
Company.connection.execute "SET IDENTITY_INSERT companies OFF"
end
- assert_raises(ActiveRecord::SubclassNotFound) { Company.find(100) }
+ assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) }
end
def test_inheritance_find
@@ -124,7 +124,7 @@ class InheritanceTest < ActiveRecord::TestCase
end
def test_finding_incorrect_type_data
- assert_raises(ActiveRecord::RecordNotFound) { Firm.find(2) }
+ assert_raise(ActiveRecord::RecordNotFound) { Firm.find(2) }
assert_nothing_raised { Firm.find(1) }
end
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb
index 077cac7747..8d2059d63f 100644
--- a/activerecord/test/cases/locking_test.rb
+++ b/activerecord/test/cases/locking_test.rb
@@ -35,7 +35,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase
assert_equal 0, p2.lock_version
p2.first_name = 'sue'
- assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
+ assert_raise(ActiveRecord::StaleObjectError) { p2.save! }
end
def test_lock_repeating
@@ -50,9 +50,9 @@ class OptimisticLockingTest < ActiveRecord::TestCase
assert_equal 0, p2.lock_version
p2.first_name = 'sue'
- assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
+ assert_raise(ActiveRecord::StaleObjectError) { p2.save! }
p2.first_name = 'sue2'
- assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
+ assert_raise(ActiveRecord::StaleObjectError) { p2.save! }
end
def test_lock_new
@@ -71,7 +71,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase
assert_equal 0, p2.lock_version
p2.first_name = 'sue'
- assert_raises(ActiveRecord::StaleObjectError) { p2.save! }
+ assert_raise(ActiveRecord::StaleObjectError) { p2.save! }
end
def test_lock_new_with_nil
@@ -95,7 +95,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase
assert_equal 0, t2.version
t2.tps_report_number = 800
- assert_raises(ActiveRecord::StaleObjectError) { t2.save! }
+ assert_raise(ActiveRecord::StaleObjectError) { t2.save! }
end
def test_lock_column_is_mass_assignable
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 710634f08a..50d039ec77 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -111,7 +111,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
end
- assert_raises(ActiveRecord::StatementInvalid) do
+ assert_raise(ActiveRecord::StatementInvalid) do
Person.connection.execute "insert into testings (foo) values (NULL)"
end
ensure
@@ -278,7 +278,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
Person.connection.add_column :testings, :bar, :string, :null => false
- assert_raises(ActiveRecord::StatementInvalid) do
+ assert_raise(ActiveRecord::StatementInvalid) do
Person.connection.execute "insert into testings (foo, bar) values ('hello', NULL)"
end
ensure
@@ -297,7 +297,7 @@ if ActiveRecord::Base.connection.supports_migrations?
Person.connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter)
assert_nothing_raised {Person.connection.add_column :testings, :bar, :string, :null => false, :default => "default" }
- assert_raises(ActiveRecord::StatementInvalid) do
+ assert_raise(ActiveRecord::StatementInvalid) do
unless current_adapter?(:OpenBaseAdapter)
Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)"
else
@@ -545,7 +545,7 @@ if ActiveRecord::Base.connection.supports_migrations?
else
ActiveRecord::ActiveRecordError
end
- assert_raises(exception) do
+ assert_raise(exception) do
Person.connection.rename_column "hats", "nonexistent", "should_fail"
end
ensure
@@ -795,7 +795,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal "hello world", Reminder.find(:first).content
WeNeedReminders.down
- assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
+ assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
end
def test_add_table_with_decimals
@@ -856,7 +856,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
GiveMeBigNumbers.down
- assert_raises(ActiveRecord::StatementInvalid) { BigNumber.find(:first) }
+ assert_raise(ActiveRecord::StatementInvalid) { BigNumber.find(:first) }
end
def test_migrator
@@ -876,7 +876,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal 0, ActiveRecord::Migrator.current_version
Person.reset_column_information
assert !Person.column_methods_hash.include?(:last_name)
- assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
+ assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
end
def test_migrator_one_up
@@ -932,7 +932,7 @@ if ActiveRecord::Base.connection.supports_migrations?
def test_migrator_one_up_with_exception_and_rollback
assert !Person.column_methods_hash.include?(:last_name)
- e = assert_raises(StandardError) do
+ e = assert_raise(StandardError) do
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/broken", 100)
end
@@ -1107,7 +1107,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal "hello world", Reminder.find(:first).content
WeNeedReminders.down
- assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
+ assert_raise(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
ensure
ActiveRecord::Base.table_name_prefix = ''
ActiveRecord::Base.table_name_suffix = ''
@@ -1137,13 +1137,13 @@ if ActiveRecord::Base.connection.supports_migrations?
end
def test_migrator_with_duplicates
- assert_raises(ActiveRecord::DuplicateMigrationVersionError) do
+ assert_raise(ActiveRecord::DuplicateMigrationVersionError) do
ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate", nil)
end
end
def test_migrator_with_duplicate_names
- assert_raises(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do
+ assert_raise(ActiveRecord::DuplicateMigrationNameError, "Multiple migrations have the name Chunky") do
ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate_names", nil)
end
end
@@ -1159,7 +1159,7 @@ if ActiveRecord::Base.connection.supports_migrations?
# table name is 29 chars, the standard sequence name will
# be 33 chars and fail
- assert_raises(ActiveRecord::StatementInvalid) do
+ assert_raise(ActiveRecord::StatementInvalid) do
begin
Person.connection.create_table :table_with_name_thats_just_ok do |t|
t.column :foo, :string, :null => false
@@ -1186,7 +1186,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
# confirm the custom sequence got dropped
- assert_raises(ActiveRecord::StatementInvalid) do
+ assert_raise(ActiveRecord::StatementInvalid) do
Person.connection.execute("select suitably_short_seq.nextval from dual")
end
end
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index 40abd935df..f9ae5115fc 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -214,7 +214,7 @@ class TransactionTest < ActiveRecord::TestCase
end
def test_invalid_keys_for_transaction
- assert_raises ArgumentError do
+ assert_raise ArgumentError do
Topic.transaction :nested => true do
end
end
@@ -370,7 +370,7 @@ class TransactionTest < ActiveRecord::TestCase
# Test now inside a transaction: add_column should raise a StatementInvalid
Topic.transaction do
- assert_raises(ActiveRecord::StatementInvalid) { Topic.connection.add_column('topics', 'stuff', :string) }
+ assert_raise(ActiveRecord::StatementInvalid) { Topic.connection.add_column('topics', 'stuff', :string) }
raise ActiveRecord::Rollback
end
end
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb
index 60e75d2f88..c20f5ae63e 100644
--- a/activerecord/test/cases/validations_test.rb
+++ b/activerecord/test/cases/validations_test.rb
@@ -114,8 +114,8 @@ class ValidationsTest < ActiveRecord::TestCase
end
def test_invalid_record_exception
- assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
- assert_raises(ActiveRecord::RecordInvalid) { Reply.new.save! }
+ assert_raise(ActiveRecord::RecordInvalid) { Reply.create! }
+ assert_raise(ActiveRecord::RecordInvalid) { Reply.new.save! }
begin
r = Reply.new
@@ -127,13 +127,13 @@ class ValidationsTest < ActiveRecord::TestCase
end
def test_exception_on_create_bang_many
- assert_raises(ActiveRecord::RecordInvalid) do
+ assert_raise(ActiveRecord::RecordInvalid) do
Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }])
end
end
def test_exception_on_create_bang_with_block
- assert_raises(ActiveRecord::RecordInvalid) do
+ assert_raise(ActiveRecord::RecordInvalid) do
Reply.create!({ "title" => "OK" }) do |r|
r.content = nil
end
@@ -141,7 +141,7 @@ class ValidationsTest < ActiveRecord::TestCase
end
def test_exception_on_create_bang_many_with_block
- assert_raises(ActiveRecord::RecordInvalid) do
+ assert_raise(ActiveRecord::RecordInvalid) do
Reply.create!([{ "title" => "OK" }, { "title" => "Wrong Create" }]) do |r|
r.content = nil
end
@@ -150,7 +150,7 @@ class ValidationsTest < ActiveRecord::TestCase
def test_scoped_create_without_attributes
Reply.with_scope(:create => {}) do
- assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
+ assert_raise(ActiveRecord::RecordInvalid) { Reply.create! }
end
end