Skip to content

Instantly share code, notes, and snippets.

@premedios
Last active August 29, 2015 14:05
Show Gist options
  • Save premedios/6cfff41612e4246b49f5 to your computer and use it in GitHub Desktop.
Save premedios/6cfff41612e4246b49f5 to your computer and use it in GitHub Desktop.
<% provide(:title, 'About Us') %>
<h1>About Us</h1>
<p>
The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
is a project to make a book and screencasts to teach web development
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
is the sample application for the tutorial.
</p>
<!DOCTYPE html>
<html>
<head>
<title>Ruby on Rails Tutorials Sample App | <%= yield(:title) %></title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
<% provide(:title, 'Help') %>
<h1>Help</h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
To get help on this sample app, see the
<a href="http://railstutorial.org/book">Rails Tutorial book</a>.
</p>
<% provide(:title, 'Home') %>
<h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
get 'static_pages/about'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Operating System: OS X Mavericks
Ruby: 2.1.2
Rails: 4.1.4
Rspec result:
Peter in ~/developer/rails/sample_app on master*
⚡ autotest
loading autotest/rails_rspec
"/Users/Peter/.rbenv/versions/2.1.2/bin/ruby" -rrubygems -S "/Users/Peter/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.3/exe/rspec" --tty "/Users/Peter/Developer/rails/sample_app/spec/requests/static_pages_spec.rb"
.F.F.F
Failures:
1) Static pages Home page should have the title 'Home'
Failure/Error: expect(page).to have_title("Ruby on Rails Tutorial Sample App | Home")
expected #has_title?("Ruby on Rails Tutorial Sample App | Home") to return true, got false
# ./spec/requests/static_pages_spec.rb:14:in `block (3 levels) in <top (required)>'
2) Static pages Help page should have the title 'Help'
Failure/Error: expect(page).to have_title('Ruby on Rails Tutorial Sample App | Help')
expected #has_title?("Ruby on Rails Tutorial Sample App | Help") to return true, got false
# ./spec/requests/static_pages_spec.rb:27:in `block (3 levels) in <top (required)>'
3) Static pages About page should have the title 'About Us'
Failure/Error: expect(page).to have_title("Ruby on Rails Tutorial Sample App | About Us");
expected #has_title?("Ruby on Rails Tutorial Sample App | About Us") to return true, got false
# ./spec/requests/static_pages_spec.rb:40:in `block (3 levels) in <top (required)>'
Finished in 0.58455 seconds (files took 8.74 seconds to load)
6 examples, 3 failures
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:12 # Static pages Home page should have the title 'Home'
rspec ./spec/requests/static_pages_spec.rb:25 # Static pages Help page should have the title 'Help'
rspec ./spec/requests/static_pages_spec.rb:38 # Static pages About page should have the title 'About Us'
require 'rails_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
it "should have the title 'Home'" do
visit '/static_pages/home'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | Home")
end
end
describe "Help page" do
it "should have the content 'Help'" do
visit '/static_pages/help'
expect(page).to have_content('Help')
end
it "should have the title 'Help'" do
visit '/static_pages/help'
expect(page).to have_title('Ruby on Rails Tutorial Sample App | Help')
end
end
describe 'About page' do
it "should have the content 'About Us'" do
visit '/static_pages/about'
expect(page).to have_content('About Us')
end
it "should have the title 'About Us'" do
visit '/static_pages/about'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | About Us");
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment