Skip to content

Commit

Permalink
Done with static pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeaddison93 committed Apr 18, 2011
1 parent a0218c0 commit b562423
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 41 deletions.
4 changes: 4 additions & 0 deletions .autotest
@@ -0,0 +1,4 @@
require 'autotest/growl'
require 'autotest/fsevent'
require 'redgreen/autotest'
require "autotest/restart"
2 changes: 2 additions & 0 deletions .rspec
@@ -1 +1,3 @@
--colour --colour
--drb

1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -14,6 +14,7 @@ end
group :test do group :test do
gem 'rspec', '2.5.0' gem 'rspec', '2.5.0'
gem 'webrat', '0.7.1' gem 'webrat', '0.7.1'
gem 'spork', '~> 0.9.0.rc'
end end


# Use unicorn as the web server # Use unicorn as the web server
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -74,6 +74,7 @@ GEM
activesupport (~> 3.0) activesupport (~> 3.0)
railties (~> 3.0) railties (~> 3.0)
rspec (~> 2.5.0) rspec (~> 2.5.0)
spork (0.9.0.rc5)
sqlite3-ruby (1.3.2) sqlite3-ruby (1.3.2)
thor (0.14.6) thor (0.14.6)
treetop (1.4.9) treetop (1.4.9)
Expand All @@ -91,5 +92,6 @@ DEPENDENCIES
rails (= 3.0.6) rails (= 3.0.6)
rspec (= 2.5.0) rspec (= 2.5.0)
rspec-rails (= 2.5.0) rspec-rails (= 2.5.0)
spork (~> 0.9.0.rc)
sqlite3-ruby (= 1.3.2) sqlite3-ruby (= 1.3.2)
webrat (= 0.7.1) webrat (= 0.7.1)
6 changes: 6 additions & 0 deletions app/controllers/pages_controller.rb
@@ -1,8 +1,14 @@
class PagesController < ApplicationController class PagesController < ApplicationController
def home def home
@title = "Home"
end end


def contact def contact
@title = "Contact"
end

def about
@title = "About"
end end


end end
18 changes: 7 additions & 11 deletions app/views/layouts/application.html.erb
@@ -1,14 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>SampleApp</title> <title>Ruby on Rails Tutorial Sample App | <%= @title %></title>
<%= stylesheet_link_tag :all %> <%= csrf_meta_tag %>
<%= javascript_include_tag :defaults %> </head>
<%= csrf_meta_tag %> <body>
</head> <%= yield %>
<body> </body>

<%= yield %>

</body>
</html> </html>
7 changes: 7 additions & 0 deletions app/views/pages/about.html.erb
@@ -0,0 +1,7 @@
<h1>About Us</h1>
<p>
<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>
7 changes: 5 additions & 2 deletions app/views/pages/contact.html.erb
@@ -1,2 +1,5 @@
<h1>Pages#contact</h1> <h1>Contact</h1>
<p>Find me in app/views/pages/contact.html.erb</p> <p>
Contact Ruby on Rails Tutorial about the sample app at the
<a href="http://railstutorial.org/feedback">feedback page</a>.
</p>
8 changes: 6 additions & 2 deletions app/views/pages/home.html.erb
@@ -1,2 +1,6 @@
<h1>Pages#home</h1> <h1>Sample App</h1>
<p>Find me in app/views/pages/home.html.erb</p> <p>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
2 changes: 1 addition & 1 deletion config/routes.rb
@@ -1,7 +1,7 @@
SampleApp::Application.routes.draw do SampleApp::Application.routes.draw do
get "pages/home" get "pages/home"

get "pages/contact" get "pages/contact"
get "pages/about"


# The priority is based upon order of creation: # The priority is based upon order of creation:
# first created -> highest priority. # first created -> highest priority.
Expand Down
27 changes: 27 additions & 0 deletions spec/controllers/pages_controller_spec.rb
@@ -1,19 +1,46 @@
require 'spec_helper' require 'spec_helper'


describe PagesController do describe PagesController do
render_views


describe "GET 'home'" do describe "GET 'home'" do
it "should be successful" do it "should be successful" do
get 'home' get 'home'
response.should be_success response.should be_success
end 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 end


describe "GET 'contact'" do describe "GET 'contact'" do
it "should be successful" do it "should be successful" do
get 'contact' get 'contact'
response.should be_success response.should be_success
end end

it "should have the right title" do
get 'contact'
response.should have_selector("title",
:content =>
"Ruby on Rails Tutorial Sample App | Contact")
end
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 end
15 changes: 0 additions & 15 deletions spec/helpers/pages_helper_spec.rb

This file was deleted.

47 changes: 47 additions & 0 deletions spec/spec_helper.rb
@@ -1,3 +1,50 @@
require 'rubygems'
require 'spork'

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.

end

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

end

# --- Instructions ---
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
# block.
#
# The Spork.prefork block is run only once when the spork server is started.
# You typically want to place most of your (slow) initializer code in here, in
# particular, require'ing any 3rd-party gems that you don't normally modify
# during development.
#
# The Spork.each_run block is run each time you run your specs. In case you
# need to load files that tend to change during development, require them here.
# With Rails, your application modules are loaded automatically, so sometimes
# this block can remain empty.
#
# Note: You can modify files loaded *from* the Spork.each_run block without
# restarting the spork server. However, this file itself will not be reloaded,
# so if you change any of the code inside the each_run block, you still need to
# restart the server. In general, if you have non-trivial code in this file,
# it's advisable to move it into a separate file so you can easily edit it
# without restarting spork. (For example, with RSpec, you could move
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
# spec/support/* files are require'd from inside the each_run block.)
#
# Any code that is left outside the two blocks will be run during preforking
# *and* during each_run -- that's probably not what you want.
#
# These instructions should self-destruct in 10 seconds. If they don't, feel
# free to delete them.




# This file is copied to spec/ when you run 'rails generate rspec:install' # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test' ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__) require File.expand_path("../../config/environment", __FILE__)
Expand Down
5 changes: 0 additions & 5 deletions spec/views/pages/contact.html.erb_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/views/pages/home.html.erb_spec.rb

This file was deleted.

0 comments on commit b562423

Please sign in to comment.