Why am I not getting the expected titles?

I'm following this tutorial: 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/, but the site was down at the time of this question.

Attachments: http://www.ruby-forum.com/attachment/4920/pages.zip

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

Attachments: http://www.ruby-forum.com/attachment/4921/application.html.erb

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

Colin Law 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?

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