# Question re assert\_equal

**URL:** <https://discuss.rubyonrails.org/t/question-re-assert-equal/55704>\
**Category:** rubyonrails-talk\
**Created:** [November 14, 2010, 9:48pm UTC](https://discuss.rubyonrails.org/t/question-re-assert-equal/55704 "2010-11-14T21:48:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![24z](https://avatars.discourse-cdn.com/v4/letter/2/e95f7d/32.png) [@24z](https://discuss.rubyonrails.org/u/24z)\
**Post date:** [November 14, 2010, 9:48pm UTC](https://discuss.rubyonrails.org/t/question-re-assert-equal/55704/1 "2010-11-14T21:48:22Z")

</div>

In Agile Web Development 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?

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [November 15, 2010, 8:20am UTC](https://discuss.rubyonrails.org/t/question-re-assert-equal/55704/2 "2010-11-15T08:20:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [November 15, 2010, 2:36pm UTC](https://discuss.rubyonrails.org/t/question-re-assert-equal/55704/3 "2010-11-15T14:36:39Z")

</div>

24z wrote in post #961471:

> In Agile Web Development 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,
