Topic: SOLVED How to test for 'title' and 'name' using Rspec and Capbara?

Following is my show.html.haml file:

    %h3
      = gravatar_for @employee
      %p
      #details
      = @employee.emp_full_name
      #spacing
      = @employee.email

Next, here is my application_helper file that defines title:

     module ApplicationHelper
     def logo
        logo = image_tag("rails.png", :alt => "Time and it's Cost", class:  "round")
     end

    # Return title on a per-page basis.
    def title
       base_title = "Time and it's Cost"
          if @title.nil?
             base_title
          else
             "#{base_title} | #{@title}"
         end
     end
end

And, here is my spec/requests/employee_pages_spec file:

     require 'spec_helper'
     describe "Employee pages" do
       subject { page }
         describe "employee show page" do
          let(:employee) { FactoryGirl.create(:employee) }
          before { visit employee_path(employee) }

          it { should have_selector('h3',  employee.emp_full_name) }
          it { should have_selector('title',  text: employee.emp_full_name) }
        end
  end

As can be seen from my 'show page', I have a 'h3' selector but I also have '#details' tag that I think is the cause of my 'h3' test failing. I am not sure how to get to the #details in order to test it? Also since my title is in application_helper I am at a loss as to how to test for it?

Anyone have some ideas they can share with me?

Thanks

p.s. I am using rails 3.2.1, ruby 1.9.3-p0 and postgresql 9.1

**update**

Okay, I have learnt that it in not a good idea to try to adapt your tests to new environment. For instance, the latest railstutorial is using Capybara over autotest, and so I thought I could just adapt the existing tests to Capybara. Well for a week or so I have been bumping my head against a brick wall unitl I learnt that I should delete Webrat from my Gemfile. So, along with revising my indentation(haml), for my home/about/contact/help views and removing Webrat from my Gemfile and generally more current on Capybara, my static page tests are beginning to pass. A big acheivement for me. I guess that closes this question.

Last edited by fuzzytom (2012-03-23 16:13:52)