Ya, it's in the layout.

<title><%= title %></title>
>

which uses the application helper

*application_helper.rb

*
>
> module ApplicationHelper
>
>   def title
>     base_title = "Provisioner"
>     if @title.nil?
>       base_title
>     else
>       "#{base_title} | #{@title}"
>     end
>   end
> end


which gets the @title from the pages controller

def contact
>     @title = "Contact"
>   end
>


On Tue, Jul 26, 2011 at 6:18 AM, Leonardo Mateo <[email protected]>wrote:

> On Mon, Jul 25, 2011 at 9:49 PM, Brian Jakovich <[email protected]>
> wrote:
> > Hi Everyone,
> >
> > I've been working with cucumber trying to tests links using the scenario
> > outline feature of cucumber. What I want to do is have it visit the
> > starting_page and then click on the specified link. It should then check
> to
> > make sure the title is correct on that page to ensure it's on the
> expected
> > page. Spent quite a bit of time googling without any luck.
> >
> > Error I've been receiving:
> >
> >> expected css "title" to return something
> >> (RSpec::Expectations::ExpectationNotMetError)
> >>       ./features/step_definitions/managing_pages_steps.rb:11:in `/^I
> >> should be able to change pages by clicking "([^"]*)" and the title is
> >> "([^"]*)"$/'
> >>       features/managing_pages.feature:12:in `Then I should be able to
> >> change pages by clicking "<link>" and the title is "<title>"'
> >
> >
> > My code is below:
> >
> > managing_pages.feature
> >
> >>
> >> Scenario Outline: As a user I need links in order to navigate the site
> >>         Given I am an anonymous user
> >>         When I am at the "<starting_page>" page
> >>         Then I should be able to change pages by clicking "<link>" and
> the
> >> title is "<title>"
> >>
> >>         Scenarios: As a user that is not logged in
> >>             |   starting_page |  link       |  title      |
> >>             |    /                  | Contact  | Contact |
> >>             |    /                  | Home     | Home    |
> >
> > managing_pages_steps.rb
> >
> >> Given /^I am an anonymous user$/ do
> >>   @user = nil
> >> end
> >>
> >> When /^I am at the "([^"]*)" page$/ do |starting_page|
> >>   visit starting_page
> >> end
> >>
> >> Then /^I should be able to change pages by clicking "([^"]*)" and the
> >> title is "([^"]*)"$/ do |page_name, title|
> >>   click_link page_name
> >>   response.should have_selector('title', :content => "Contact")
> >> end
> >
> >
> > application_helper.rb
> >
> >> module ApplicationHelper
> >>
> >>   def title
> >>     base_title = "Provisioner"
> >>     if @title.nil?
> >>       base_title
> >>     else
> >>       "#{base_title} | #{@title}"
> >>     end
> >>   end
> >> end
> >
> > pages_controller.rb
> >
> >>
> >> class PagesController < ApplicationController
> >>   def home
> >>     @title = "Home"
> >>   end
> >>
> >>   def contact
> >>     @title = "Contact"
> >>   end
> >> end
> >
> > layouts/application.html.erb
> >
> >> <!DOCTYPE html>
> >> <html>
> >>   <head>
> >>     <title><%= title %></title>
> >>     <%= stylesheet_link_tag :all %>
> >>     <%= javascript_include_tag :defaults %>
> >>     <%= csrf_meta_tag %>
> >>     <%= link_to "Contact", contact_path %>
> >>     <%= link_to "Home", root_path %>
> >>   </head>
> >>   <body>
> >>
> >>     <%= yield %>
> >>
> >>   </body>
> >> </html>
> >
> >
> >
> > Any help is much appreciated!
>
> You're getting this error
> >> expected css "title" to return something
> >> (RSpec::Expectations::ExpectationNotMetError)
>
> Webrat is expecting a <title> html tag. You're usign have_selector and
> you're specifying a tagname. Do you have something like
> <title>Contact</title> in that page?
>
> >>response.should have_selector('title', :content => "Contact")
>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/rubyonrails-talk?hl=en.
> >
>
>
>
> --
> Leonardo Mateo.
> There's no place like ~
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to