This project is archived and is in readonly mode.

#4643 ✓invalid
Neeraj Singh

Use assert_kind_of whenever possible instead of assert

Reported by Neeraj Singh | May 18th, 2010 @ 05:06 PM | in 3.x

Patch will be attached through comment.

Comments and changes to this ticket

  • Neeraj Singh

    Neeraj Singh May 18th, 2010 @ 05:08 PM

    • Tag changed from rails3, test to patch, rails3, test
    • Assigned user set to “José Valim”

    Attached is patch.

  • Santiago Pastorino

    Santiago Pastorino May 18th, 2010 @ 11:17 PM

    • Milestone set to 3.x
    • State changed from “new” to “verified”

    Is ok but do the same i said on #4644

    $ grep -r 'assert ' * | grep is_a

    and

    $ grep -r 'assert ' * | grep kind_of

    i get the following ...

    actionpack/test/controller/new_base/bare_metal_test.rb: assert part.is_a?(String), "Each part of the body must be a String"
    activemodel/lib/active_model/lint.rb: assert model.errors[:hello].is_a?(Array), "errors#[] should return an Array"
    activemodel/lib/active_model/lint.rb: assert model.errors.full_messages.is_a?(Array), "errors#full_messages should return an Array"
    activerecord/test/cases/query_cache_test.rb: assert Task.connection.select_value("SELECT count(*) AS count_all FROM tasks").is_a?(Numeric)
    activerecord/test/cases/fixtures_test.rb: assert fixture.is_a?(Fixtures)
    activesupport/test/safe_buffer_test.rb: assert @buffer.is_a?(String)
    activesupport/test/core_ext/time_with_zone_test.rb: assert result.is_a?(Float)
    activesupport/test/core_ext/time_with_zone_test.rb: assert result.is_a?(Integer)
    activesupport/test/core_ext/time_with_zone_test.rb: assert @twz.is_a?(Time)
    activesupport/test/core_ext/time_with_zone_test.rb: assert @twz.is_a?(ActiveSupport::TimeWithZone)
    activesupport/test/core_ext/duration_test.rb: assert d.is_a?(ActiveSupport::Duration)
    activesupport/test/core_ext/duration_test.rb: assert d.is_a?(Numeric)
    activesupport/test/core_ext/duration_test.rb: assert d.is_a?(Fixnum)
    activesupport/test/core_ext/duration_test.rb: assert !d.is_a?(Hash)
    activesupport/test/core_ext/duration_test.rb: assert !d.is_a?(k)
    activesupport/test/core_ext/date_time_ext_test.rb: assert DateTime.current.is_a?(DateTime)
    activesupport/test/core_ext/date_time_ext_test.rb: assert DateTime.current.is_a?(DateTime)
    railties/test/application/rackup_test.rb: assert Rails.application.is_a?(Rails::Application)
    railties/test/application/rackup_test.rb: assert ActionController::Dispatcher.new.is_a?(Rails::Application)
    activerecord/test/cases/inheritance_test.rb: assert Company.find(1).kind_of?(Firm), "37signals should be a firm"
    activerecord/test/cases/inheritance_test.rb: assert Firm.find(1).kind_of?(Firm), "37signals should be a firm"
    activerecord/test/cases/inheritance_test.rb: assert Company.find(2).kind_of?(Client), "Summit should be a client"
    activerecord/test/cases/inheritance_test.rb: assert Client.find(2).kind_of?(Client), "Summit should be a client"
    activerecord/test/cases/inheritance_test.rb: assert companies[0].kind_of?(Firm), "37signals should be a firm"
    activerecord/test/cases/inheritance_test.rb: assert companies[1].kind_of?(Client), "Summit should be a client"
    activerecord/test/cases/inheritance_test.rb: assert next_angle.kind_of?(Firm), "Next Angle should be a firm"
    activesupport/test/core_ext/time_with_zone_test.rb: assert @twz.kind_of?(Time)
    activesupport/test/core_ext/string_ext_test.rb: assert UNICODE_STRING.mb_chars.kind_of?(String)
    activesupport/test/core_ext/string_ext_test.rb: assert UNICODE_STRING.mb_chars.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/core_ext/string_ext_test.rb: assert UNICODE_STRING.mb_chars.kind_of?(String)
    activesupport/test/multibyte_chars_test.rb: assert @chars.method_for_multibyte_testing.kind_of?(@proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert @chars.
    method_for_multibyte_testing!.kind_of?(@proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert character.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').insert(0, '').kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').rjust(1).kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').ljust(1).kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').center(1).kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').rstrip.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').lstrip.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').strip.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').reverse.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars(' ').slice(0).kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').limit(0).kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').upcase.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').downcase.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').capitalize.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').normalize.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').decompose.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').compose.kind_of?(ActiveSupport::Multibyte.proxy_class)
    activesupport/test/multibyte_chars_test.rb: assert chars('').tidy_bytes.kind_of?(ActiveSupport::Multibyte.proxy_class)

  • Neeraj Singh

    Neeraj Singh May 19th, 2010 @ 02:29 AM

    attached is revised patch.

    I am spent last few days looking at rails test. So I am going through all the tests one by one trying to understand it and fixing it as I go along. I am done 50% of the files and now I need to take a break. Hence I am sending all the work done as patch.

    I will take a look at other test files in second iteration.

  • Neeraj Singh

    Neeraj Singh May 19th, 2010 @ 02:51 AM

    This ticket can be closed. I am providing patch through #4645 .

  • Santiago Pastorino

    Santiago Pastorino May 19th, 2010 @ 03:19 AM

    • State changed from “verified” to “invalid”
  • bingbing

    bingbing March 26th, 2011 @ 02:10 AM

    • Importance changed from “” to “Low”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages