Skip to content

Commit e639e90

Browse files
committed
Add an About page
1 parent 2beea31 commit e639e90

12 files changed

+207
-47
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ doc/
1515
*~
1616
.project
1717
.DS_Store
18-
.idea
18+
.idea
19+
.rvmrc

.rspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
--color
1+
--colour
2+
--drb

Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ gem 'rails', '4.0.0.beta1'
55
group :development, :test do
66
gem 'sqlite3', '1.3.7'
77
gem 'rspec-rails', '2.13.0'
8+
gem 'guard-rspec', '2.5.0'
9+
gem 'spork-rails', github: 'railstutorial/spork-rails', branch: 'rails-4'
10+
gem 'guard-spork', '1.5.0'
811
end
912

1013
group :test do
1114
gem 'capybara', '2.0.2'
15+
gem 'rb-fsevent', '0.9.3', :require => false
16+
gem 'growl', '1.0.3'
1217
end
1318

1419
group :assets do

Gemfile.lock

+43
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
GIT
2+
remote: git://github.com/railstutorial/spork-rails.git
3+
revision: 8b49e3d6ea85b2f1d23eb3fb148b7e971eb4e614
4+
branch: rails-4
5+
specs:
6+
spork-rails (3.2.1)
7+
spork (>= 1.0rc0)
8+
19
GEM
210
remote: https://rubygems.org/
311
specs:
@@ -37,6 +45,7 @@ GEM
3745
xpath (~> 1.0.0)
3846
childprocess (0.3.9)
3947
ffi (~> 1.0, >= 1.0.11)
48+
coderay (1.0.9)
4049
coffee-rails (4.0.0.beta1)
4150
coffee-script (>= 2.2.0)
4251
railties (>= 4.0.0.beta, < 5.0)
@@ -49,6 +58,20 @@ GEM
4958
execjs (1.4.0)
5059
multi_json (~> 1.0)
5160
ffi (1.4.0)
61+
growl (1.0.3)
62+
guard (1.6.2)
63+
listen (>= 0.6.0)
64+
lumberjack (>= 1.0.2)
65+
pry (>= 0.9.10)
66+
terminal-table (>= 1.4.3)
67+
thor (>= 0.14.6)
68+
guard-rspec (2.5.0)
69+
guard (>= 1.1)
70+
rspec (~> 2.11)
71+
guard-spork (1.5.0)
72+
childprocess (>= 0.2.3)
73+
guard (>= 1.1)
74+
spork (>= 0.8.4)
5275
hike (1.2.1)
5376
i18n (0.6.4)
5477
jbuilder (1.0.1)
@@ -57,16 +80,23 @@ GEM
5780
railties (>= 3.0, < 5.0)
5881
thor (>= 0.14, < 2.0)
5982
json (1.7.7)
83+
listen (0.7.3)
84+
lumberjack (1.0.2)
6085
mail (2.5.3)
6186
i18n (>= 0.4.0)
6287
mime-types (~> 1.16)
6388
treetop (~> 1.4.8)
89+
method_source (0.8.1)
6490
mime-types (1.21)
6591
minitest (4.6.2)
6692
multi_json (1.6.1)
6793
nokogiri (1.5.6)
6894
pg (0.14.1)
6995
polyglot (0.3.3)
96+
pry (0.9.12)
97+
coderay (~> 1.0.5)
98+
method_source (~> 0.8)
99+
slop (~> 3.4)
70100
rack (1.5.2)
71101
rack-test (0.6.2)
72102
rack (>= 1.0)
@@ -85,8 +115,13 @@ GEM
85115
rdoc (~> 3.4)
86116
thor (>= 0.17.0, < 2.0)
87117
rake (10.0.3)
118+
rb-fsevent (0.9.3)
88119
rdoc (3.12.2)
89120
json (~> 1.4)
121+
rspec (2.13.0)
122+
rspec-core (~> 2.13.0)
123+
rspec-expectations (~> 2.13.0)
124+
rspec-mocks (~> 2.13.0)
90125
rspec-core (2.13.0)
91126
rspec-expectations (2.13.0)
92127
diff-lcs (>= 1.1.3, < 2.0)
@@ -110,6 +145,8 @@ GEM
110145
multi_json (~> 1.0)
111146
rubyzip
112147
websocket (~> 1.0.4)
148+
slop (3.4.3)
149+
spork (1.0.0rc3)
113150
sprockets (2.9.0)
114151
hike (~> 1.2)
115152
multi_json (~> 1.0)
@@ -120,6 +157,7 @@ GEM
120157
activesupport (>= 3.0)
121158
sprockets (~> 2.8)
122159
sqlite3 (1.3.7)
160+
terminal-table (1.4.5)
123161
thor (0.17.0)
124162
thread_safe (0.1.0)
125163
atomic
@@ -143,12 +181,17 @@ PLATFORMS
143181
DEPENDENCIES
144182
capybara (= 2.0.2)
145183
coffee-rails (= 4.0.0.beta1)
184+
growl (= 1.0.3)
185+
guard-rspec (= 2.5.0)
186+
guard-spork (= 1.5.0)
146187
jbuilder (= 1.0.1)
147188
jquery-rails (= 2.2.1)
148189
pg (= 0.14.1)
149190
rails (= 4.0.0.beta1)
191+
rb-fsevent (= 0.9.3)
150192
rspec-rails (= 2.13.0)
151193
sass-rails (= 4.0.0.beta1)
194+
spork-rails!
152195
sqlite3 (= 1.3.7)
153196
turbolinks (= 1.0.0)
154197
uglifier (= 1.0.3)

Guardfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' },
5+
:rspec_env => { 'RAILS_ENV' => 'test' } do
6+
watch('config/application.rb')
7+
watch('config/environment.rb')
8+
watch('config/environments/test.rb')
9+
watch(%r{^config/initializers/.+\.rb$})
10+
watch('Gemfile')
11+
watch('Gemfile.lock')
12+
watch('spec/spec_helper.rb') { :rspec }
13+
watch('test/test_helper.rb') { :test_unit }
14+
watch(%r{features/support/}) { :cucumber }
15+
end
16+
17+
guard 'rspec', after_all_pass: false, cli: '--drb' do
18+
watch(%r{^spec/.+_spec\.rb$})
19+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
20+
watch('spec/spec_helper.rb') { "spec" }
21+
22+
# Rails example
23+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
24+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
25+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
26+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
27+
watch('config/routes.rb') { "spec/routing" }
28+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
29+
30+
# Capybara features specs
31+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
32+
33+
# Turnip features and steps
34+
watch(%r{^spec/acceptance/(.+)\.feature$})
35+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
36+
37+
# Custom Rails Tutorial specs
38+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
39+
["spec/routing/#{m[1]}_routing_spec.rb",
40+
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
41+
"spec/acceptance/#{m[1]}_spec.rb",
42+
(m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
43+
"spec/requests/#{m[1].singularize}_pages_spec.rb")]
44+
end
45+
watch(%r{^app/views/(.+)/}) do |m|
46+
(m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
47+
"spec/requests/#{m[1].singularize}_pages_spec.rb")
48+
end
49+
watch(%r{^app/controllers/sessions_controller\.rb$}) do |m|
50+
"spec/requests/authentication_pages_spec.rb"
51+
end
52+
end

app/controllers/static_pages_controller.rb

+3
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ def home
44

55
def help
66
end
7+
8+
# def about
9+
# end
710
end

app/views/static_pages/about.html.erb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h1>About Us</h1>
2+
<p>
3+
The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
4+
is a project to make a book and screencasts to teach web development
5+
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
6+
is the sample application for the tutorial.
7+
</p>

app/views/static_pages/help.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
<h1>StaticPages#help</h1>
2-
<p>Find me in app/views/static_pages/help.html.erb</p>
1+
<h1>Help</h1>
2+
<p>
3+
Get help on the Ruby on Rails Tutorial at the
4+
<a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
5+
To get help on this sample app, see the
6+
<a href="http://railstutorial.org/book">Rails Tutorial book</a>.
7+
</p>

app/views/static_pages/home.html.erb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
<h1>StaticPages#home</h1>
2-
<p>Find me in app/views/static_pages/home.html.erb</p>
1+
<h1>Sample App</h1>
2+
<p>
3+
This is the home page for the
4+
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
5+
sample application.
6+
</p>

config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SampleApp::Application.routes.draw do
22
get "static_pages/home"
33
get "static_pages/help"
4+
get "static_pages/about"
45
# The priority is based upon order of creation: first created -> highest priority.
56
# See how all your routes lay out with "rake routes".
67

spec/requests/static_pages_spec.rb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'spec_helper'
2+
3+
describe "Static pages" do
4+
5+
describe "Home page" do
6+
7+
it "should have the content 'Sample App'" do
8+
visit '/static_pages/home'
9+
expect(page).to have_content('Sample App')
10+
end
11+
end
12+
13+
describe "Help page" do
14+
15+
it "should have the content 'Help'" do
16+
visit '/static_pages/help'
17+
expect(page).to have_content('Help')
18+
end
19+
end
20+
21+
describe "About page" do
22+
23+
it "should have the content 'About Us'" do
24+
visit '/static_pages/about'
25+
expect(page).to have_content('About Us')
26+
end
27+
end
28+
end

spec/spec_helper.rb

+51-41
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
1-
# This file is copied to spec/ when you run 'rails generate rspec:install'
2-
ENV["RAILS_ENV"] ||= 'test'
3-
require File.expand_path("../../config/environment", __FILE__)
4-
require 'rspec/rails'
5-
require 'rspec/autorun'
6-
7-
# Requires supporting ruby files with custom matchers and macros, etc,
8-
# in spec/support/ and its subdirectories.
9-
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10-
11-
# Checks for pending migrations before tests are run.
12-
# If you are not using ActiveRecord, you can remove this line.
13-
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
14-
15-
RSpec.configure do |config|
16-
# ## Mock Framework
17-
#
18-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
19-
#
20-
# config.mock_with :mocha
21-
# config.mock_with :flexmock
22-
# config.mock_with :rr
23-
24-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
25-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
26-
27-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
28-
# examples within a transaction, remove the following line or assign false
29-
# instead of true.
30-
config.use_transactional_fixtures = true
31-
32-
# If true, the base class of anonymous controllers will be inferred
33-
# automatically. This will be the default behavior in future versions of
34-
# rspec-rails.
35-
config.infer_base_class_for_anonymous_controllers = false
36-
37-
# Run specs in random order to surface order dependencies. If you find an
38-
# order dependency and want to debug it, you can fix the order by providing
39-
# the seed, which is printed after each run.
40-
# --seed 1234
41-
config.order = "random"
1+
require 'rubygems'
2+
require 'spork'
3+
4+
Spork.prefork do
5+
ENV["RAILS_ENV"] ||= 'test'
6+
require File.expand_path("../../config/environment", __FILE__)
7+
require 'rspec/rails'
8+
require 'rspec/autorun'
9+
10+
# Requires supporting ruby files with custom matchers and macros, etc,
11+
# in spec/support/ and its subdirectories.
12+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
13+
14+
# Checks for pending migrations before tests are run.
15+
# If you are not using ActiveRecord, you can remove this line.
16+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
17+
18+
RSpec.configure do |config|
19+
# ## Mock Framework
20+
#
21+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
22+
#
23+
# config.mock_with :mocha
24+
# config.mock_with :flexmock
25+
# config.mock_with :rr
26+
27+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
28+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
29+
30+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
31+
# examples within a transaction, remove the following line or assign false
32+
# instead of true.
33+
config.use_transactional_fixtures = true
34+
35+
# If true, the base class of anonymous controllers will be inferred
36+
# automatically. This will be the default behavior in future versions of
37+
# rspec-rails.
38+
config.infer_base_class_for_anonymous_controllers = false
39+
40+
# Run specs in random order to surface order dependencies. If you find an
41+
# order dependency and want to debug it, you can fix the order by providing
42+
# the seed, which is printed after each run.
43+
# --seed 1234
44+
config.order = "random"
45+
config.include Capybara::DSL
46+
end
47+
end
48+
49+
Spork.each_run do
50+
# This code will be run each time you run your specs.
51+
4252
end

0 commit comments

Comments
 (0)