Showing posts with label Test Driven Development (TDD). Show all posts
Showing posts with label Test Driven Development (TDD). Show all posts

Tuesday, 25 June 2013

Rails Factory Girl, Stubs and Mocks

Useful Links :

  1. http://stackoverflow.com/questions/5183975/factory-girl-whats-the-purpose
  2. http://stackoverflow.com/questions/5164102/mocks-and-stubs

Michael Hartl tutorial Chapter 7. Error: " expected css "title" with text "Michael Hartl" to return something"

While passing the test for the show method of user, the test fail due to the following error.
Failures:

  1) User pages profile page
     Failure/Error: it { should have_selector('title', text: user.name) }
       expected css "title" with text "Michael Hartl" to return something
     # ./spec/requests/user_pages_spec.rb:18:in `block (3 levels) in <top (required)>'

Finished in 2.22 seconds
33 examples, 1 failure

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:18 # User pages profile page
This is because of the helper tag in "app/views/users/show.html.erb"
 Replace
<% provide(:title, @user.name) %>
with 
 <title><%= @user.name%></title>

Monday, 24 June 2013

Static pages should have the right links on the layout

While practising Michael Hartl's Rails tutorial, when I want to test the links. One test is failing with the following error message.
Error: "Static pages should have the right links on the layout
This can be fixed by putting "visit root_path" before  click_link "Sign up now!"
screen shot of the code is given below.
___________________
it "should have the right links on the layout" do
    visit root_path
    click_link "About"
    page.should have_selector 'title', text: full_title('About Us')
    click_link "Help"
    page.should # fill in
    click_link "Contact"
    page.should # fill in
    click_link "Home"
    visit root_path
    click_link "Sign up now!"
    page.should # fill in
    click_link "sample app"
    page.should # fill in
  end
____________________


 Useful Links :