Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pages_controllers_spec.rb
- ___________________________
- require 'spec_helper'
- describe PagesController do
- render_views
- describe "GET 'home'" do
- it "should be successful" do
- get 'home'
- response.should be_success
- end
- it "should have the right title" do
- get 'home'
- response.should have_selector("title",
- :content => "Ruby on Rails Tutorial Sample App | Home")
- end
- end
- describe "GET 'contact'" do
- it "should be successful" do
- get 'contact'
- response.should be_success
- end
- it "should have the right title" do
- get 'contact'
- response.should be_selector("title",
- :content => "Ruby on Rails Tutorial Sample App | Contact")
- end
- end
- describe "GET 'about'" do
- it "should be successful" do
- get 'about'
- response.should be_success
- end
- it "should have the right title" do
- get 'about'
- response.should have_selector("title",
- :content => "Ruby on Rails Tutorial Sample App | About")
- end
- end
- end
- ____________________
- application.html.erb
- <!DOCTYPE html>
- <html>
- <head>
- <title>Ruby on Rails Tutorial Sample App | <%= @title %></title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
- </head>
- <body>
- <%= yield %>
- </body>
- </html>
- _____________________
- pages.controller.rb
- class PagesController < ApplicationController
- def home
- @title = "Home"
- end
- def contact
- @title = "Contact"
- end
- def about
- @title = "About"
- end
- end
- ____________________
- about.html.erb
- <!doctype html>
- <html lang="en">
- <head>
- <title>Ruby on Rails Tutorial Sample App | About</title>
- </head>
- <body>
- <h1>About Us</h1>
- <p>This is the about page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application.</p>
- </body>
- </html>
- ____________
- home.html.erb
- <!doctype html>
- <html lang="en">
- <head>
- <title>Ruby on Rails Tutorial Sample App | Home</title>
- </head>
- <body>
- <h1>Home</h1>
- <p>This is the home page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application.</p>
- </body>
- </html>
- ____________________-
- contact.html.erb
- <!doctype html>
- <html lang="en">
- <head>
- <title>Ruby on Rails Tutorial Sample App | Contact</title>
- </head>
- <body>
- <h1>Contact</h1>
- <p>This is the contact page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application.
- </p>
- </body>
- </html>
- ____________________
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement