Question re assert_equal

In Agile Web D. with Rails, the following statement is given:

assert_equal “has already been taken”, product.errors[:title].join(’;
')

My question is: Why is the join(…) needed and what exactly does it
do here?

If it does what I assume, join an array of strings and use "; " as the
separator, then I wonder how the assert_equal statement could ever
evaluate to true as the first parameter is a static string without ";
"

Can you shed some light for me?

On Nov 14, 9:48pm, 24z [email protected] wrote:

evaluate to true as the first parameter is a static string without ";
"

Can you shed some light for me?

If there is only supposed to be one error on title (ie the
errors[:title] contains a single string) then join will just return
that string. Hard to say without knowing the wider context, but this
seems a fairly succinct way of saying that there should only be one
error for the title attribute and that it should be the one that comes
from the uniqueness validation.

Fred

24z wrote in post #961471:

In Agile Web D. with Rails, the following statement is given:

assert_equal “has already been taken”, product.errors[:title].join(';
')

My question is: Why is the join(…) needed and what exactly does it
do here?

If it does what I assume, join an array of strings and use "; " as the
separator, then I wonder how the assert_equal statement could ever
evaluate to true as the first parameter is a static string without ";
"

That seems like a strangely written assertion. Obviously, the only way
it could return true is if product.errors[:title] has only one element.

Can you shed some light for me?

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]