# Why am I not getting the expected titles?

**URL:** <https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899>\
**Category:** Rails\
**Created:** [August 7, 2010, 11:57pm UTC](https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899 "2010-08-07T23:57:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 7, 2010, 11:57pm UTC](https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899/1 "2010-08-07T23:57:12Z")

</div>

I’m following this tutorial:  
[http://railstutorial.org/chapters/static-pages#sec:red](http://railstutorial.org/chapters/static-pages#sec:red)

And have passed the tests that confirm that every pages has the relevant  
title.

When I run the application I always get the title bar as “SampleApp”,  
although I have the views with different title as shown in the  
attachment.

I was going to show the code using [http://pastie.org/](http://pastie.org/), but the site was  
down at the time of this question.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 8, 2010, 12:23am UTC](https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899/2 "2010-08-08T00:23:19Z")

</div>

This worked when I modified application.html.erb as shown in the  
attachment, as it had the title as “SampleApp”

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 8, 2010, 8:44am UTC](https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899/3 "2010-08-08T08:44:04Z")

</div>

On 7 August 2010 23:23, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This worked when I modified application.html.erb as shown in the  
> attachment, as it had the title as “SampleApp”

How was it that your tests worked then? It is important when writing  
tests to write them before the code. Your tests on the title should  
therefore have failed initially (as you had not yet supplied the  
title). This helps to guard against errors in the test code not  
actually testing what you intended, as I presume was the case here.

Colin

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 8, 2010, 11:56am UTC](https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899/4 "2010-08-08T11:56:56Z")

</div>

Colin L. wrote:

> On 7 August 2010 23:23, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > This worked when I modified application.html.erb as shown in the  
> > attachment, as it had the title as “SampleApp”
> 
> How was it that your tests worked then? It is important when writing  
> tests to write them before the code. Your tests on the title should  
> therefore have failed initially (as you had not yet supplied the  
> title). This helps to guard against errors in the test code not  
> actually testing what you intended, as I presume was the case here.
> 
> Colin

I actually wrote the tests before, and have provided the titles, but the  
strange thing was that I was always getting “SampleApp” as the title.

So, the tests passes since the titles were in every page I made a test  
for.

In order to remove the “SampleApp” title, I had to modify  
application.html.erb.

This is what happened. What do you think?

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 8, 2010, 5:23pm UTC](https://www.ruby-forum.com/t/why-am-i-not-getting-the-expected-titles/192899/5 "2010-08-08T17:23:47Z")

</div>

On 8 August 2010 10:56, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Colin
> 
> I actually wrote the tests before, and have provided the titles, but the  
> strange thing was that I was always getting “SampleApp” as the title.
> 
> So, the tests passes since the titles were in every page I made a test  
> for.

I don’t understand, if all the titles were ‘SampleApp’ how did the  
tests pass, since they presumably were checking for the correct  
titles?

Colin
