Skip to content

Commit

Permalink
Finish static pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed Mar 8, 2012
1 parent be325fb commit 76538f4
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
/log/*.log
/tmp
vendor/ruby
bundler_stubs/
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--colour
--drb
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gem 'jquery-rails', '2.0.0'

group :test do
gem 'capybara', '1.1.2'
gem 'spork', '0.9.0'
end

group :production do
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ GEM
ffi (~> 1.0)
multi_json (~> 1.0)
rubyzip
spork (0.9.0)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
Expand Down Expand Up @@ -144,5 +145,6 @@ DEPENDENCIES
rails (= 3.2.2)
rspec-rails (= 2.8.1)
sass-rails (= 3.2.3)
spork (= 0.9.0)
sqlite3 (= 1.3.5)
uglifier (= 1.2.3)
3 changes: 3 additions & 0 deletions app/assets/javascripts/static_pages.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/static_pages.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the StaticPages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
10 changes: 10 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class StaticPagesController < ApplicationController
def home
end

def help
end

def about
end
end
2 changes: 2 additions & 0 deletions app/helpers/static_pages_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module StaticPagesHelper
end
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>SampleApp</title>
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
Expand Down
8 changes: 8 additions & 0 deletions app/views/static_pages/about.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= 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>
8 changes: 8 additions & 0 deletions app/views/static_pages/help.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= 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>
7 changes: 7 additions & 0 deletions app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= 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>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
SampleApp::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.

Expand Down
46 changes: 46 additions & 0 deletions spec/requests/static_pages_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'spec_helper'

describe "Static pages" do

describe "Home page" do

it "should have the h1 'Sample App'" do
visit '/static_pages/home'
page.should have_selector('h1', :text => 'Sample App')
end

it "should have the title 'Home'" do
visit '/static_pages/home'
page.should have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | Home")
end
end

describe "Help page" do

it "should have the h1 'Help'" do
visit '/static_pages/help'
page.should have_selector('h1', :text => 'Help')
end

it "should have the title 'Help'" do
visit '/static_pages/help'
page.should have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | Help")
end
end

describe "About page" do

it "should have the h1 'About'" do
visit '/static_pages/about'
page.should have_selector('h1', :text => 'About Us')
end

it "should have the title 'About Us'" do
visit '/static_pages/about'
page.should have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | About Us")
end
end
end
21 changes: 21 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
Expand Down Expand Up @@ -30,3 +39,15 @@
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
end
end

Spork.each_run do
# This code will be run each time you run your specs.

end






Binary file added vendor/cache/spork-0.9.0.gem
Binary file not shown.

0 comments on commit 76538f4

Please sign in to comment.