Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1476 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

[PATCH] whiny nil test

Reported by: court3nay Assigned to: David
Priority: normal Milestone: 1.0
Component: ActiveRecord Version: 0.12.1
Severity: normal Keywords:
Cc: court3nay@gmail.com

Description

Test for whiny nil id method

def test_id
    begin
      nil.id
    rescue RuntimeError => nme
      assert(!(nme.message =~ /nil:NilClass/))
    end
  end

Attachments

.2 (0 bytes) - added by anonymous on 06/21/05 22:52:47.
whiny_nil_test_for_id.diff (468 bytes) - added by court3nay@gmail.com on 06/21/05 22:53:10.
AS-whiny-nil-id-test-and-make-the-tests-runnable-1476.patch (1.8 kB) - added by marcel on 06/22/05 10:14:30.

Change History

06/21/05 22:52:47 changed by anonymous

  • attachment .2 added.

06/21/05 22:53:10 changed by court3nay@gmail.com

  • attachment whiny_nil_test_for_id.diff added.

06/22/05 10:01:12 changed by marcel

  • summary changed from whiny nil test to [PATCH] whiny nil test.

06/22/05 10:14:05 changed by marcel

All the test methods for Whiny nil have superfluous begin and end. Defining a method wraps an implicit begin/end block around the method body which means you can do

def something
  raise
rescue
  'hi'
end

rather than

def something
  begin
    raise
  rescue
    'hi'
  end
end

Added patch which gets rid of the begin/end and incorporates court3nay's patch.

Also makes tests runnable by disambiguating AR and Array's namespace.

N.B. You must require active record to run the tests.

ruby -r /path/to/active_record whiny_nil_test.rb

06/22/05 10:14:30 changed by marcel

  • attachment AS-whiny-nil-id-test-and-make-the-tests-runnable-1476.patch added.

06/25/05 11:15:49 changed by david

  • status changed from new to closed.
  • resolution set to fixed.