1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Final iteration of use better testing methods

[#4652 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Neeraj Singh 2010-05-19 15:14:51 -04:00 committed by José Valim
parent bdb2871df7
commit 39a246f545
25 changed files with 82 additions and 82 deletions

View file

@ -255,7 +255,7 @@ class FinderTest < ActiveRecord::TestCase
assert !topic.attribute_present?("title") assert !topic.attribute_present?("title")
#assert !topic.respond_to?("title") #assert !topic.respond_to?("title")
assert topic.attribute_present?("author_name") assert topic.attribute_present?("author_name")
assert topic.respond_to?("author_name") assert_respond_to topic, "author_name"
end end
def test_find_on_blank_conditions def test_find_on_blank_conditions

View file

@ -72,10 +72,10 @@ class InheritanceTest < ActiveRecord::TestCase
end end
def test_inheritance_find def test_inheritance_find
assert Company.find(1).kind_of?(Firm), "37signals should be a firm" assert_kind_of Firm, Company.find(1), "37signals should be a firm"
assert Firm.find(1).kind_of?(Firm), "37signals should be a firm" assert_kind_of Firm, Firm.find(1), "37signals should be a firm"
assert Company.find(2).kind_of?(Client), "Summit should be a client" assert_kind_of Client, Company.find(2), "Summit should be a client"
assert Client.find(2).kind_of?(Client), "Summit should be a client" assert_kind_of Client, Client.find(2), "Summit should be a client"
end end
def test_alt_inheritance_find def test_alt_inheritance_find
@ -86,8 +86,8 @@ class InheritanceTest < ActiveRecord::TestCase
def test_inheritance_find_all def test_inheritance_find_all
companies = Company.find(:all, :order => 'id') companies = Company.find(:all, :order => 'id')
assert companies[0].kind_of?(Firm), "37signals should be a firm" assert_kind_of Firm, companies[0], "37signals should be a firm"
assert companies[1].kind_of?(Client), "Summit should be a client" assert_kind_of Client, companies[1], "Summit should be a client"
end end
def test_alt_inheritance_find_all def test_alt_inheritance_find_all
@ -102,7 +102,7 @@ class InheritanceTest < ActiveRecord::TestCase
firm.save firm.save
next_angle = Company.find(firm.id) next_angle = Company.find(firm.id)
assert next_angle.kind_of?(Firm), "Next Angle should be a firm" assert_kind_of Firm, next_angle, "Next Angle should be a firm"
end end
def test_alt_inheritance_save def test_alt_inheritance_save

View file

@ -622,7 +622,7 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal ['salary DESC'], klass.scoped.order_values assert_equal ['salary DESC'], klass.scoped.order_values
# Parent should still have the original scope # Parent should still have the original scope
assert_equal nil, DeveloperOrderedBySalary.scoped.limit_value assert_nil DeveloperOrderedBySalary.scoped.limit_value
assert_equal ['salary DESC'], DeveloperOrderedBySalary.scoped.order_values assert_equal ['salary DESC'], DeveloperOrderedBySalary.scoped.order_values
end end

View file

@ -525,7 +525,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end end
end end
assert_equal TrueClass, bob.male?.class assert_instance_of TrueClass, bob.male?
assert_kind_of BigDecimal, bob.wealth assert_kind_of BigDecimal, bob.wealth
end end

View file

@ -18,7 +18,7 @@ class PrimaryKeysTest < ActiveRecord::TestCase
def test_to_key_with_customized_primary_key def test_to_key_with_customized_primary_key
keyboard = Keyboard.new keyboard = Keyboard.new
assert keyboard.to_key.nil? assert_nil keyboard.to_key
keyboard.save keyboard.save
assert_equal keyboard.to_key, [keyboard.id] assert_equal keyboard.to_key, [keyboard.id]
end end
@ -37,7 +37,7 @@ class PrimaryKeysTest < ActiveRecord::TestCase
topic = Topic.new topic = Topic.new
topic.title = "New Topic" topic.title = "New Topic"
assert_equal(nil, topic.id) assert_nil topic.id
assert_nothing_raised { topic.save! } assert_nothing_raised { topic.save! }
id = topic.id id = topic.id

View file

@ -58,7 +58,7 @@ class QueryCacheTest < ActiveRecord::TestCase
Task.cache do Task.cache do
# Oracle adapter returns count() as Fixnum or Float # Oracle adapter returns count() as Fixnum or Float
if current_adapter?(:OracleAdapter) if current_adapter?(:OracleAdapter)
assert Task.connection.select_value("SELECT count(*) AS count_all FROM tasks").is_a?(Numeric) assert_kind_of Numeric, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
elsif current_adapter?(:SQLite3Adapter) && SQLite3::Version::VERSION > '1.2.5' elsif current_adapter?(:SQLite3Adapter) && SQLite3::Version::VERSION > '1.2.5'
# Future versions of the sqlite3 adapter will return numeric # Future versions of the sqlite3 adapter will return numeric
assert_instance_of Fixnum, assert_instance_of Fixnum,

View file

@ -145,7 +145,7 @@ class RelationTest < ActiveRecord::TestCase
relation = Topic.scoped relation = Topic.scoped
["map", "uniq", "sort", "insert", "delete", "update"].each do |method| ["map", "uniq", "sort", "insert", "delete", "update"].each do |method|
assert relation.respond_to?(method), "Topic.scoped should respond to #{method.inspect}" assert_respond_to relation, method, "Topic.scoped should respond to #{method.inspect}"
end end
end end
@ -160,7 +160,7 @@ class RelationTest < ActiveRecord::TestCase
relation = Topic.scoped relation = Topic.scoped
["find_by_title", "find_by_title_and_author_name", "find_or_create_by_title", "find_or_initialize_by_title_and_author_name"].each do |method| ["find_by_title", "find_by_title_and_author_name", "find_or_create_by_title", "find_or_initialize_by_title_and_author_name"].each do |method|
assert relation.respond_to?(method), "Topic.scoped should respond to #{method.inspect}" assert_respond_to relation, method, "Topic.scoped should respond to #{method.inspect}"
end end
end end
@ -238,7 +238,7 @@ class RelationTest < ActiveRecord::TestCase
def test_default_scope_with_conditions_string def test_default_scope_with_conditions_string
assert_equal Developer.find_all_by_name('David').map(&:id).sort, DeveloperCalledDavid.scoped.map(&:id).sort assert_equal Developer.find_all_by_name('David').map(&:id).sort, DeveloperCalledDavid.scoped.map(&:id).sort
assert_equal nil, DeveloperCalledDavid.create!.name assert_nil DeveloperCalledDavid.create!.name
end end
def test_default_scope_with_conditions_hash def test_default_scope_with_conditions_hash

View file

@ -115,7 +115,7 @@ class MysqlReservedWordTest < ActiveRecord::TestCase
create_test_fixtures :select, :distinct, :group, :values, :distincts_selects create_test_fixtures :select, :distinct, :group, :values, :distincts_selects
v = nil v = nil
assert_nothing_raised { v = Group.find(1).values } assert_nothing_raised { v = Group.find(1).values }
assert_equal v.id, 2 assert_equal 2, v.id
end end
# belongs_to association with reserved-word table name # belongs_to association with reserved-word table name

View file

@ -15,26 +15,26 @@ class TimestampTest < ActiveRecord::TestCase
@developer.name = "Jack Bauer" @developer.name = "Jack Bauer"
@developer.save! @developer.save!
assert @previously_updated_at != @developer.updated_at assert_not_equal @previously_updated_at, @developer.updated_at
end end
def test_saving_a_unchanged_record_doesnt_update_its_timestamp def test_saving_a_unchanged_record_doesnt_update_its_timestamp
@developer.save! @developer.save!
assert @previously_updated_at == @developer.updated_at assert_equal @previously_updated_at, @developer.updated_at
end end
def test_touching_a_record_updates_its_timestamp def test_touching_a_record_updates_its_timestamp
@developer.touch @developer.touch
assert @previously_updated_at != @developer.updated_at assert_not_equal @previously_updated_at, @developer.updated_at
end end
def test_touching_a_different_attribute def test_touching_a_different_attribute
previously_created_at = @developer.created_at previously_created_at = @developer.created_at
@developer.touch(:created_at) @developer.touch(:created_at)
assert previously_created_at != @developer.created_at assert_not_equal previously_created_at, @developer.created_at
end end
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at
@ -45,7 +45,7 @@ class TimestampTest < ActiveRecord::TestCase
pet.name = "Fluffy the Third" pet.name = "Fluffy the Third"
pet.save pet.save
assert previously_owner_updated_at != pet.owner.updated_at assert_not_equal previously_owner_updated_at, pet.owner.updated_at
end end
def test_destroying_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at def test_destroying_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at
@ -55,7 +55,7 @@ class TimestampTest < ActiveRecord::TestCase
pet.destroy pet.destroy
assert previously_owner_updated_at != pet.owner.updated_at assert_not_equal previously_owner_updated_at, pet.owner.updated_at
end end
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_attribute_the_parent_should_update_that_attribute def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_attribute_the_parent_should_update_that_attribute
@ -68,8 +68,8 @@ class TimestampTest < ActiveRecord::TestCase
pet.name = "Fluffy the Third" pet.name = "Fluffy the Third"
pet.save pet.save
assert previously_owner_happy_at != pet.owner.happy_at assert_not_equal previously_owner_happy_at, pet.owner.happy_at
ensure ensure
Pet.belongs_to :owner, :touch => true Pet.belongs_to :owner, :touch => true
end end
end end

View file

@ -185,7 +185,7 @@ class SchemaTest < ActiveModel::TestCase
#### ####
test "should be able to use schema" do test "should be able to use schema" do
assert Person.respond_to?(:schema), "should at least respond to the schema method" assert_respond_to Person, :schema, "should at least respond to the schema method"
assert_nothing_raised("Should allow the schema to take a block") do assert_nothing_raised("Should allow the schema to take a block") do
Person.schema { } Person.schema { }
@ -199,7 +199,7 @@ class SchemaTest < ActiveModel::TestCase
s = self s = self
attribute :foo, :string attribute :foo, :string
end end
assert s.respond_to?(:attrs), "should return attributes in theory" assert_respond_to s, :attrs, "should return attributes in theory"
assert_equal({'foo' => 'string' }, s.attrs, "should return attributes in practice") assert_equal({'foo' => 'string' }, s.attrs, "should return attributes in practice")
end end
end end
@ -308,8 +308,8 @@ class SchemaTest < ActiveModel::TestCase
Person.schema { string new_attr_name_two } Person.schema { string new_attr_name_two }
end end
assert Person.new.respond_to?(new_attr_name), "should respond to the attribute in a passed-in schema, but failed on: #{new_attr_name}" assert_respond_to Person.new, new_attr_name, "should respond to the attribute in a passed-in schema, but failed on: #{new_attr_name}"
assert Person.new.respond_to?(new_attr_name_two), "should respond to the attribute from the schema, but failed on: #{new_attr_name_two}" assert_respond_to Person.new, new_attr_name_two, "should respond to the attribute from the schema, but failed on: #{new_attr_name_two}"
end end
test "should not care about ordering of schema definitions" do test "should not care about ordering of schema definitions" do
@ -326,8 +326,8 @@ class SchemaTest < ActiveModel::TestCase
Person.schema = {new_attr_name.to_s => 'string'} Person.schema = {new_attr_name.to_s => 'string'}
end end
assert Person.new.respond_to?(new_attr_name), "should respond to the attribute in a passed-in schema, but failed on: #{new_attr_name}" assert_respond_to Person.new, new_attr_name, "should respond to the attribute in a passed-in schema, but failed on: #{new_attr_name}"
assert Person.new.respond_to?(new_attr_name_two), "should respond to the attribute from the schema, but failed on: #{new_attr_name_two}" assert_respond_to Person.new, new_attr_name_two, "should respond to the attribute from the schema, but failed on: #{new_attr_name_two}"
end end
# method_missing effects # method_missing effects

View file

@ -671,9 +671,9 @@ class BaseTest < Test::Unit::TestCase
######################################################################## ########################################################################
def test_respond_to def test_respond_to
matz = Person.find(1) matz = Person.find(1)
assert matz.respond_to?(:name) assert_respond_to matz, :name
assert matz.respond_to?(:name=) assert_respond_to matz, :name=
assert matz.respond_to?(:name?) assert_respond_to matz, :name?
assert !matz.respond_to?(:super_scalable_stuff) assert !matz.respond_to?(:super_scalable_stuff)
end end
@ -708,7 +708,7 @@ class BaseTest < Test::Unit::TestCase
def test_id_from_response_without_location def test_id_from_response_without_location
p = Person.new p = Person.new
resp = {} resp = {}
assert_equal nil, p.__send__(:id_from_response, resp) assert_nil p.__send__(:id_from_response, resp)
end end
def test_create_with_custom_prefix def test_create_with_custom_prefix
@ -775,7 +775,7 @@ class BaseTest < Test::Unit::TestCase
mock.post "/people.xml", {}, nil, 201 mock.post "/people.xml", {}, nil, 201
end end
person = Person.create(:name => 'Rick') person = Person.create(:name => 'Rick')
assert_equal nil, person.id assert_nil person.id
end end
def test_clone def test_clone

View file

@ -521,7 +521,7 @@ module CallbacksTest
def test_save def test_save
obj = HyphenatedCallbacks.new obj = HyphenatedCallbacks.new
obj.save obj.save
assert_equal obj.stuff, "ACTION" assert_equal "ACTION", obj.stuff
end end
end end
end end

View file

@ -25,14 +25,14 @@ class ClassAttributeAccessorTest < Test::Unit::TestCase
end end
def test_should_not_create_instance_writer def test_should_not_create_instance_writer
assert @class.respond_to?(:foo) assert_respond_to @class, :foo
assert @class.respond_to?(:foo=) assert_respond_to @class, :foo=
assert @object.respond_to?(:bar) assert_respond_to @object, :bar
assert !@object.respond_to?(:bar=) assert !@object.respond_to?(:bar=)
end end
def test_should_not_create_instance_reader def test_should_not_create_instance_reader
assert @class.respond_to?(:shaq) assert_respond_to @class, :shaq
assert !@object.respond_to?(:shaq) assert !@object.respond_to?(:shaq)
end end
end end

View file

@ -219,7 +219,7 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase
@klass.reset_inheritable_attributes @klass.reset_inheritable_attributes
@sub = eval("class NotInheriting < @klass; end; NotInheriting") @sub = eval("class NotInheriting < @klass; end; NotInheriting")
assert_equal nil, @klass.a assert_nil @klass.a
assert_equal nil, @sub.a assert_nil @sub.a
end end
end end

View file

@ -32,16 +32,16 @@ class DelegatingAttributesTest < Test::Unit::TestCase
single_class.superclass_delegating_accessor :both single_class.superclass_delegating_accessor :both
# Class should have accessor and mutator # Class should have accessor and mutator
# the instance should have an accessor only # the instance should have an accessor only
assert single_class.respond_to?(:both) assert_respond_to single_class, :both
assert single_class.respond_to?(:both=) assert_respond_to single_class, :both=
assert single_class.public_instance_methods.map(&:to_s).include?("both") assert single_class.public_instance_methods.map(&:to_s).include?("both")
assert !single_class.public_instance_methods.map(&:to_s).include?("both=") assert !single_class.public_instance_methods.map(&:to_s).include?("both=")
end end
def test_simple_accessor_declaration_with_instance_reader_false def test_simple_accessor_declaration_with_instance_reader_false
single_class.superclass_delegating_accessor :no_instance_reader, :instance_reader => false single_class.superclass_delegating_accessor :no_instance_reader, :instance_reader => false
assert single_class.respond_to?(:no_instance_reader) assert_respond_to single_class, :no_instance_reader
assert single_class.respond_to?(:no_instance_reader=) assert_respond_to single_class, :no_instance_reader=
assert !single_class.public_instance_methods.map(&:to_s).include?("no_instance_reader") assert !single_class.public_instance_methods.map(&:to_s).include?("no_instance_reader")
end end

View file

@ -275,12 +275,12 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase
end end
def test_current_without_time_zone def test_current_without_time_zone
assert DateTime.current.is_a?(DateTime) assert_kind_of DateTime, DateTime.current
end end
def test_current_with_time_zone def test_current_with_time_zone
with_env_tz 'US/Eastern' do with_env_tz 'US/Eastern' do
assert DateTime.current.is_a?(DateTime) assert_kind_of DateTime, DateTime.current
end end
end end

View file

@ -5,8 +5,8 @@ class DurationTest < ActiveSupport::TestCase
def test_is_a def test_is_a
d = 1.day d = 1.day
assert d.is_a?(ActiveSupport::Duration) assert d.is_a?(ActiveSupport::Duration)
assert d.is_a?(Numeric) assert_kind_of Numeric, d
assert d.is_a?(Fixnum) assert_kind_of Fixnum, d
assert !d.is_a?(Hash) assert !d.is_a?(Hash)
k = Class.new k = Class.new

View file

@ -27,14 +27,14 @@ class ModuleAttributeAccessorTest < Test::Unit::TestCase
end end
def test_should_not_create_instance_writer def test_should_not_create_instance_writer
assert @module.respond_to?(:foo) assert_respond_to @module, :foo
assert @module.respond_to?(:foo=) assert_respond_to @module, :foo=
assert @object.respond_to?(:bar) assert_respond_to @object, :bar
assert !@object.respond_to?(:bar=) assert !@object.respond_to?(:bar=)
end end
def test_should_not_create_instance_reader def test_should_not_create_instance_reader
assert @module.respond_to?(:shaq) assert_respond_to @module, :shaq
assert !@object.respond_to?(:shaq) assert !@object.respond_to?(:shaq)
end end
end end

View file

@ -16,8 +16,8 @@ class SynchronizationTest < Test::Unit::TestCase
attr_accessor :value attr_accessor :value
synchronize :value, :with => :mutex synchronize :value, :with => :mutex
end end
assert @instance.respond_to?(:value_with_synchronization) assert_respond_to @instance, :value_with_synchronization
assert @instance.respond_to?(:value_without_synchronization) assert_respond_to @instance, :value_without_synchronization
end end
def test_synchronize_does_not_change_behavior def test_synchronize_does_not_change_behavior
@ -81,7 +81,7 @@ class SynchronizationTest < Test::Unit::TestCase
class << @target class << @target
synchronize :to_s, :with => :mutex synchronize :to_s, :with => :mutex
end end
assert @target.respond_to?(:to_s_without_synchronization) assert_respond_to @target, :to_s_without_synchronization
assert_nothing_raised { @target.to_s; @target.to_s } assert_nothing_raised { @target.to_s; @target.to_s }
assert_equal 2, @target.mutex.sync_count assert_equal 2, @target.mutex.sync_count
end end

View file

@ -225,7 +225,7 @@ class MethodAliasingTest < Test::Unit::TestCase
FooClassWithBarMethod.class_eval { include BarMethodAliaser } FooClassWithBarMethod.class_eval { include BarMethodAliaser }
feature_aliases.each do |method| feature_aliases.each do |method|
assert @instance.respond_to?(method) assert_respond_to @instance, method
end end
assert_equal 'bar_with_baz', @instance.bar assert_equal 'bar_with_baz', @instance.bar
@ -242,7 +242,7 @@ class MethodAliasingTest < Test::Unit::TestCase
include BarMethodAliaser include BarMethodAliaser
alias_method_chain :quux!, :baz alias_method_chain :quux!, :baz
end end
assert @instance.respond_to?(:quux_with_baz!) assert_respond_to @instance, :quux_with_baz!
assert_equal 'quux_with_baz', @instance.quux! assert_equal 'quux_with_baz', @instance.quux!
assert_equal 'quux', @instance.quux_without_baz! assert_equal 'quux', @instance.quux_without_baz!
@ -260,9 +260,9 @@ class MethodAliasingTest < Test::Unit::TestCase
assert !@instance.respond_to?(:quux_with_baz=) assert !@instance.respond_to?(:quux_with_baz=)
FooClassWithBarMethod.class_eval { include BarMethodAliaser } FooClassWithBarMethod.class_eval { include BarMethodAliaser }
assert @instance.respond_to?(:quux_with_baz!) assert_respond_to @instance, :quux_with_baz!
assert @instance.respond_to?(:quux_with_baz?) assert_respond_to @instance, :quux_with_baz?
assert @instance.respond_to?(:quux_with_baz=) assert_respond_to @instance, :quux_with_baz=
FooClassWithBarMethod.alias_method_chain :quux!, :baz FooClassWithBarMethod.alias_method_chain :quux!, :baz

View file

@ -117,7 +117,7 @@ class StringInflectionsTest < Test::Unit::TestCase
assert_equal Time.local(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time(:local) assert_equal Time.local(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time(:local)
assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time
assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local) assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local)
assert_equal nil, "".to_time assert_nil "".to_time
end end
def test_string_to_datetime def test_string_to_datetime
@ -125,12 +125,12 @@ class StringInflectionsTest < Test::Unit::TestCase
assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset
assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value
assert_equal DateTime.civil(2039, 2, 27, 23, 50, 19 + Rational(275038, 1000000), "-04:00"), "2039-02-27T23:50:19.275038-04:00".to_datetime assert_equal DateTime.civil(2039, 2, 27, 23, 50, 19 + Rational(275038, 1000000), "-04:00"), "2039-02-27T23:50:19.275038-04:00".to_datetime
assert_equal nil, "".to_datetime assert_nil "".to_datetime
end end
def test_string_to_date def test_string_to_date
assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date
assert_equal nil, "".to_date assert_nil "".to_date
end end
def test_access def test_access
@ -224,7 +224,7 @@ class CoreExtStringMultibyteTest < ActiveSupport::TestCase
BYTE_STRING = "\270\236\010\210\245" BYTE_STRING = "\270\236\010\210\245"
def test_core_ext_adds_mb_chars def test_core_ext_adds_mb_chars
assert UNICODE_STRING.respond_to?(:mb_chars) assert_respond_to UNICODE_STRING, :mb_chars
end end
def test_string_should_recognize_utf8_strings def test_string_should_recognize_utf8_strings
@ -236,20 +236,20 @@ class CoreExtStringMultibyteTest < ActiveSupport::TestCase
if RUBY_VERSION < '1.9' if RUBY_VERSION < '1.9'
def test_mb_chars_returns_self_when_kcode_not_set def test_mb_chars_returns_self_when_kcode_not_set
with_kcode('none') do with_kcode('none') do
assert UNICODE_STRING.mb_chars.kind_of?(String) assert_kind_of String, UNICODE_STRING.mb_chars
end end
end end
def test_mb_chars_returns_an_instance_of_the_chars_proxy_when_kcode_utf8 def test_mb_chars_returns_an_instance_of_the_chars_proxy_when_kcode_utf8
with_kcode('UTF8') do with_kcode('UTF8') do
assert UNICODE_STRING.mb_chars.kind_of?(ActiveSupport::Multibyte.proxy_class) assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars
end end
end end
end end
if RUBY_VERSION >= '1.9' if RUBY_VERSION >= '1.9'
def test_mb_chars_returns_string def test_mb_chars_returns_string
assert UNICODE_STRING.mb_chars.kind_of?(String) assert_kind_of String, UNICODE_STRING.mb_chars
end end
end end
end end

View file

@ -279,13 +279,13 @@ class TimeWithZoneTest < Test::Unit::TestCase
def test_to_f def test_to_f
result = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Hawaii'] ).to_f result = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Hawaii'] ).to_f
assert_equal 946684800.0, result assert_equal 946684800.0, result
assert result.is_a?(Float) assert_kind_of Float, result
end end
def test_to_i def test_to_i
result = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Hawaii'] ).to_i result = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Hawaii'] ).to_i
assert_equal 946684800, result assert_equal 946684800, result
assert result.is_a?(Integer) assert_kind_of Integer, result
end end
def test_to_i_with_wrapped_datetime def test_to_i_with_wrapped_datetime
@ -324,9 +324,9 @@ class TimeWithZoneTest < Test::Unit::TestCase
end end
def test_is_a def test_is_a
assert @twz.is_a?(Time) assert_kind_of Time, @twz
assert @twz.kind_of?(Time) assert_kind_of Time, @twz
assert @twz.is_a?(ActiveSupport::TimeWithZone) assert ActiveSupport::TimeWithZone, @twz
end end
def test_class_name def test_class_name
@ -830,7 +830,7 @@ class TimeWithZoneMethodsForTimeAndDateTimeTest < Test::Unit::TestCase
assert_raise(TZInfo::InvalidTimezoneIdentifier) { Time.zone.utc_offset } assert_raise(TZInfo::InvalidTimezoneIdentifier) { Time.zone.utc_offset }
Time.zone = -15.hours Time.zone = -15.hours
assert_equal nil, Time.zone assert_nil Time.zone
end end
def test_current_returns_time_now_when_zone_default_not_set def test_current_returns_time_now_when_zone_default_not_set

View file

@ -31,12 +31,12 @@ class MultibyteCharsTest < Test::Unit::TestCase
end end
def test_forwarded_method_calls_should_return_new_chars_instance def test_forwarded_method_calls_should_return_new_chars_instance
assert @chars.__method_for_multibyte_testing.kind_of?(@proxy_class) assert_kind_of @proxy_class, @chars.__method_for_multibyte_testing
assert_not_equal @chars.object_id, @chars.__method_for_multibyte_testing.object_id assert_not_equal @chars.object_id, @chars.__method_for_multibyte_testing.object_id
end end
def test_forwarded_bang_method_calls_should_return_the_original_chars_instance def test_forwarded_bang_method_calls_should_return_the_original_chars_instance
assert @chars.__method_for_multibyte_testing!.kind_of?(@proxy_class) assert_kind_of @proxy_class, @chars.__method_for_multibyte_testing!
assert_equal @chars.object_id, @chars.__method_for_multibyte_testing!.object_id assert_equal @chars.object_id, @chars.__method_for_multibyte_testing!.object_id
end end
@ -114,7 +114,7 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
if RUBY_VERSION < '1.9' if RUBY_VERSION < '1.9'
def test_split_should_return_an_array_of_chars_instances def test_split_should_return_an_array_of_chars_instances
@chars.split(//).each do |character| @chars.split(//).each do |character|
assert character.kind_of?(ActiveSupport::Multibyte.proxy_class) assert_kind_of ActiveSupport::Multibyte.proxy_class, character
end end
end end

View file

@ -22,7 +22,7 @@ class TimeZoneTest < Test::Unit::TestCase
ActiveSupport::TimeZone::MAPPING.keys.each do |name| ActiveSupport::TimeZone::MAPPING.keys.each do |name|
define_method("test_map_#{name.downcase.gsub(/[^a-z]/, '_')}_to_tzinfo") do define_method("test_map_#{name.downcase.gsub(/[^a-z]/, '_')}_to_tzinfo") do
zone = ActiveSupport::TimeZone[name] zone = ActiveSupport::TimeZone[name]
assert zone.tzinfo.respond_to?(:period_for_local) assert_respond_to zone.tzinfo, :period_for_local
end end
end end

View file

@ -28,14 +28,14 @@ module ApplicationTests
test "Rails.application is available after config.ru has been racked up" do test "Rails.application is available after config.ru has been racked up" do
rackup rackup
assert Rails.application.is_a?(Rails::Application) assert_kind_of Rails::Application, Rails.application
end end
# Passenger still uses AC::Dispatcher, so we need to # Passenger still uses AC::Dispatcher, so we need to
# keep it working for now # keep it working for now
test "deprecated ActionController::Dispatcher still works" do test "deprecated ActionController::Dispatcher still works" do
rackup rackup
assert ActionController::Dispatcher.new.is_a?(Rails::Application) assert_kind_of? Rails::Application, ActionController::Dispatcher.new
end end
test "the config object is available on the application object" do test "the config object is available on the application object" do