# Review: ActiveRecord tests

**URL:** <https://www.ruby-forum.com/t/review-activerecord-tests/182206>\
**Category:** IronRuby\
**Created:** [January 25, 2010, 6:55am UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206 "2010-01-25T06:55:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [January 25, 2010, 6:55am UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206/1 "2010-01-25T06:55:32Z")

</div>

tfpt review /shelveset:ar;sborde

Enables active\_record tests in irtests.rb. They require SQLExpress to be  
installed on the machine.

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [January 25, 2010, 7:28pm UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206/2 "2010-01-25T19:28:59Z")

</div>

Utr.rb:  
Please replace @disabled = 0 if @disabled == nil with @disabled ||= 0

Why are we undefining methods instead of aliasing them to noop? I’m not  
pulled too strongly in either direction, but I’d like to know. If we are  
going to undef, then get rid of the noop definition.

Generate\_test-unit\_tags.rb:  
Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:

faults.map {|e| test\_method\_name(e)}.uniq

Rest looks good.

JD

From: Shri B.  
Sent: Sunday, January 24, 2010 9:55 PM  
To: IronRuby External Code R.  
Cc: removed\_email\_address@domain.invalid  
Subject: Review: ActiveRecord tests

tfpt review /shelveset:ar;sborde

Enables active\_record tests in irtests.rb. They require SQLExpress to be  
installed on the machine.

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [January 25, 2010, 8:13pm UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206/3 "2010-01-25T20:13:28Z")

</div>

Inline…

From: Jim D.  
Sent: Monday, January 25, 2010 10:22 AM  
To: Shri B.; IronRuby External Code R.  
Cc: removed\_email\_address@domain.invalid  
Subject: RE: Review: ActiveRecord tests

Utr.rb:  
Please replace @disabled = 0 if @disabled == nil with @disabled ||= 0  
[Shri B.] Sounds good

Why are we undefining methods instead of aliasing them to noop? I’m not  
pulled too strongly in either direction, but I’d like to know. If we are  
going to undef, then get rid of the noop definition.  
[Shri B.] Aliasing to noop will still causes setup and teardown of  
the test to run, and there can be (and are) errors in those methods,  
resulting in an error associated with the test. Undefing fixes this.  
Will get rid of noop.

Generate\_test-unit\_tags.rb:  
Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:

faults.map {|e| test\_method\_name(e)}.uniq  
[Shri B.] The issue is that there can be two different faults for a  
test, one a failure and one an error. I want to keep just one of these  
so that we emit just one “disable ClassName, :test\_name” line. #uniq  
does not work because the faults will not compare as equal.

Rest looks good.

JD

From: Shri B.  
Sent: Sunday, January 24, 2010 9:55 PM  
To: IronRuby External Code R.  
Cc: removed\_email\_address@domain.invalid  
Subject: Review: ActiveRecord tests

tfpt review /shelveset:ar;sborde

Enables active\_record tests in irtests.rb. They require SQLExpress to be  
installed on the machine.

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [January 25, 2010, 8:30pm UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206/4 "2010-01-25T20:30:27Z")

</div>

> Generate\_test-unit\_tags.rb:  
> Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:
> 
> faults.map {|e| test\_method\_name(e)}.uniq  
> [Shri B.] The issue is that there can be two different faults for a test, one a failure and one an error. I want to keep just one of these so that we emit just one \>“disable ClassName, :test\_name” line. #uniq does not work because the faults will not compare as equal.

I thought include used the same equal call as uniq, or is there  
something else going on here?

JD

From: Shri B.  
Sent: Monday, January 25, 2010 11:10 AM  
To: Jim D.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

Inline…

From: Jim D.  
Sent: Monday, January 25, 2010 10:22 AM  
To: Shri B.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

Utr.rb:  
Please replace @disabled = 0 if @disabled == nil with @disabled ||= 0  
[Shri B.] Sounds good

Why are we undefining methods instead of aliasing them to noop? I’m not  
pulled too strongly in either direction, but I’d like to know. If we are  
going to undef, then get rid of the noop definition.  
[Shri B.] Aliasing to noop will still causes setup and teardown of  
the test to run, and there can be (and are) errors in those methods,  
resulting in an error associated with the test. Undefing fixes this.  
Will get rid of noop.

Generate\_test-unit\_tags.rb:  
Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:

faults.map {|e| test\_method\_name(e)}.uniq  
[Shri B.] The issue is that there can be two different faults for a  
test, one a failure and one an error. I want to keep just one of these  
so that we emit just one “disable ClassName, :test\_name” line. #uniq  
does not work because the faults will not compare as equal.

Rest looks good.

JD

From: Shri B.  
Sent: Sunday, January 24, 2010 9:55 PM  
To: IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Review: ActiveRecord tests

tfpt review /shelveset:ar;sborde

Enables active\_record tests in irtests.rb. They require SQLExpress to be  
installed on the machine.

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [January 25, 2010, 10:03pm UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206/5 "2010-01-25T22:03:33Z")

</div>

My bad, I see what’s going on. You are rejecting faults based on the  
condition, not the string method names. Looks good.

JD

From: Shri B.  
Sent: Monday, January 25, 2010 12:21 PM  
To: Jim D.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

“faults.map {|e| test\_method\_name(e)}.uniq” will give you a unique set  
of method names. I need an array of faults with a unique set of method  
names. If uniq took a block like sort does, that would work.

From: Jim D.  
Sent: Monday, January 25, 2010 11:18 AM  
To: Shri B.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

> Generate\_test-unit\_tags.rb:  
> Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:
> 
> faults.map {|e| test\_method\_name(e)}.uniq  
> [Shri B.] The issue is that there can be two different faults for a test, one a failure and one an error. I want to keep just one of these so that we emit just one \>“disable ClassName, :test\_name” line. #uniq does not work because the faults will not compare as equal.

I thought include used the same equal call as uniq, or is there  
something else going on here?

JD

From: Shri B.  
Sent: Monday, January 25, 2010 11:10 AM  
To: Jim D.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

Inline…

From: Jim D.  
Sent: Monday, January 25, 2010 10:22 AM  
To: Shri B.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

Utr.rb:  
Please replace @disabled = 0 if @disabled == nil with @disabled ||= 0  
[Shri B.] Sounds good

Why are we undefining methods instead of aliasing them to noop? I’m not  
pulled too strongly in either direction, but I’d like to know. If we are  
going to undef, then get rid of the noop definition.  
[Shri B.] Aliasing to noop will still causes setup and teardown of  
the test to run, and there can be (and are) errors in those methods,  
resulting in an error associated with the test. Undefing fixes this.  
Will get rid of noop.

Generate\_test-unit\_tags.rb:  
Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:

faults.map {|e| test\_method\_name(e)}.uniq  
[Shri B.] The issue is that there can be two different faults for a  
test, one a failure and one an error. I want to keep just one of these  
so that we emit just one “disable ClassName, :test\_name” line. #uniq  
does not work because the faults will not compare as equal.

Rest looks good.

JD

From: Shri B.  
Sent: Sunday, January 24, 2010 9:55 PM  
To: IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Review: ActiveRecord tests

tfpt review /shelveset:ar;sborde

Enables active\_record tests in irtests.rb. They require SQLExpress to be  
installed on the machine.

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [January 25, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/review-activerecord-tests/182206/6 "2010-01-25T21:54:11Z")

</div>

“faults.map {|e| test\_method\_name(e)}.uniq” will give you a unique set  
of method names. I need an array of faults with a unique set of method  
names. If uniq took a block like sort does, that would work.

From: Jim D.  
Sent: Monday, January 25, 2010 11:18 AM  
To: Shri B.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

> Generate\_test-unit\_tags.rb:  
> Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:
> 
> faults.map {|e| test\_method\_name(e)}.uniq  
> [Shri B.] The issue is that there can be two different faults for a test, one a failure and one an error. I want to keep just one of these so that we emit just one \>“disable ClassName, :test\_name” line. #uniq does not work because the faults will not compare as equal.

I thought include used the same equal call as uniq, or is there  
something else going on here?

JD

From: Shri B.  
Sent: Monday, January 25, 2010 11:10 AM  
To: Jim D.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

Inline…

From: Jim D.  
Sent: Monday, January 25, 2010 10:22 AM  
To: Shri B.; IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: RE: Review: ActiveRecord tests

Utr.rb:  
Please replace @disabled = 0 if @disabled == nil with @disabled ||= 0  
[Shri B.] Sounds good

Why are we undefining methods instead of aliasing them to noop? I’m not  
pulled too strongly in either direction, but I’d like to know. If we are  
going to undef, then get rid of the noop definition.  
[Shri B.] Aliasing to noop will still causes setup and teardown of  
the test to run, and there can be (and are) errors in those methods,  
resulting in an error associated with the test. Undefing fixes this.  
Will get rid of noop.

Generate\_test-unit\_tags.rb:  
Couldn’t all of ensure\_single\_fault\_per\_method\_name be accomplished by:

faults.map {|e| test\_method\_name(e)}.uniq  
[Shri B.] The issue is that there can be two different faults for a  
test, one a failure and one an error. I want to keep just one of these  
so that we emit just one “disable ClassName, :test\_name” line. #uniq  
does not work because the faults will not compare as equal.

Rest looks good.

JD

From: Shri B.  
Sent: Sunday, January 24, 2010 9:55 PM  
To: IronRuby External Code R.  
Cc: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Review: ActiveRecord tests

tfpt review /shelveset:ar;sborde

Enables active\_record tests in irtests.rb. They require SQLExpress to be  
installed on the machine.
