tft_rails_dbc 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/.rvmrc +1 -0
- data/Gemfile +8 -0
- data/LICENSE +57 -0
- data/README.md +90 -0
- data/Rakefile +25 -0
- data/lib/generators/chapter07/begin/USAGE +27 -0
- data/lib/generators/chapter07/begin/begin_generator.rb +39 -0
- data/lib/generators/chapter07/begin/instructions.md +74 -0
- data/lib/generators/chapter07/begin/templates/app/controllers/application_controller.rb +8 -0
- data/lib/generators/chapter07/begin/templates/app/controllers/pages_controller.rb +11 -0
- data/lib/generators/chapter07/begin/templates/app/controllers/users_controller.rb +3 -0
- data/lib/generators/chapter07/begin/templates/app/helpers/application_helper.rb +12 -0
- data/lib/generators/chapter07/begin/templates/app/helpers/pages_helper.rb +2 -0
- data/lib/generators/chapter07/begin/templates/app/helpers/users_helper.rb +7 -0
- data/lib/generators/chapter07/begin/templates/app/models/user.rb +9 -0
- data/lib/generators/chapter07/begin/templates/app/views/layouts/_footer.html.erb +9 -0
- data/lib/generators/chapter07/begin/templates/app/views/layouts/_header.html.erb +10 -0
- data/lib/generators/chapter07/begin/templates/app/views/layouts/_stylesheets.html.erb +7 -0
- data/lib/generators/chapter07/begin/templates/app/views/layouts/application.html.erb +17 -0
- data/lib/generators/chapter07/begin/templates/app/views/pages/about.html.erb +7 -0
- data/lib/generators/chapter07/begin/templates/app/views/pages/contact.html.erb +5 -0
- data/lib/generators/chapter07/begin/templates/app/views/pages/home.html.erb +7 -0
- data/lib/generators/chapter07/begin/templates/app/views/users/show.html.erb +15 -0
- data/lib/generators/chapter07/begin/templates/config/initializers/devise.rb +194 -0
- data/lib/generators/chapter07/begin/templates/config/locales/devise.en.yml +50 -0
- data/lib/generators/chapter07/begin/templates/config/routes.rb.tt +17 -0
- data/lib/generators/chapter07/begin/templates/db/migrate/20110608224650_devise_create_users.rb +29 -0
- data/lib/generators/chapter07/begin/templates/db/schema.rb +34 -0
- data/lib/generators/chapter07/begin/templates/public/images/logo.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/ie.css +36 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/lock.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/screen.css +42 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/rtl/screen.css +110 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/print.css +29 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/screen.css +265 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/forms.css +82 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/grid.css +280 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/grid.png +0 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/ie.css +79 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/print.css +92 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/reset.css +65 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/typography.css +123 -0
- data/lib/generators/chapter07/begin/templates/public/stylesheets/custom.css +137 -0
- data/lib/generators/chapter07/begin/templates/spec/controllers/pages_controller_07_spec.rb +48 -0
- data/lib/generators/chapter07/begin/templates/spec/controllers/users_controller_07_spec.rb +38 -0
- data/lib/generators/chapter07/begin/templates/spec/factories.rb +9 -0
- data/lib/generators/chapter07/begin/templates/spec/models/user_07_spec.rb +38 -0
- data/lib/generators/chapter07/begin/templates/spec/requests/layout_links_07_spec.rb +44 -0
- data/lib/generators/chapter07/begin/templates/spec/spec_helper.rb +39 -0
- data/lib/generators/chapter07/solutions/USAGE +21 -0
- data/lib/generators/chapter07/solutions/solutions_generator.rb +23 -0
- data/lib/generators/chapter07/solutions/templates/app/controllers/pages_controller.rb +18 -0
- data/lib/generators/chapter07/solutions/templates/app/controllers/users_controller.rb +8 -0
- data/lib/generators/chapter07/solutions/templates/app/models/user.rb +11 -0
- data/lib/generators/chapter07/solutions/templates/app/views/layouts/_footer.html.erb +10 -0
- data/lib/generators/chapter07/solutions/templates/app/views/layouts/_header.html.erb +11 -0
- data/lib/generators/chapter07/solutions/templates/app/views/pages/help.html.erb +4 -0
- data/lib/generators/chapter07/solutions/templates/app/views/pages/home.html.erb +7 -0
- data/lib/generators/chapter07/solutions/templates/app/views/users/show.html.erb +15 -0
- data/lib/generators/chapter08_09/begin/USAGE +24 -0
- data/lib/generators/chapter08_09/begin/begin_generator.rb +29 -0
- data/lib/generators/chapter08_09/begin/instructions.md +65 -0
- data/lib/generators/chapter08_09/begin/snippets/custom.css +49 -0
- data/lib/generators/chapter08_09/begin/templates/spec/controllers/devise/registrations_controller_08_spec.rb +83 -0
- data/lib/generators/chapter08_09/begin/templates/spec/requests/layout_links_09_spec.rb +35 -0
- data/lib/generators/chapter08_09/begin/templates/spec/requests/users_signup_08_spec.rb +36 -0
- data/lib/generators/chapter08_09/solutions/USAGE +18 -0
- data/lib/generators/chapter08_09/solutions/solutions_generator.rb +12 -0
- data/lib/generators/chapter08_09/solutions/templates/app/helpers/application_helper.rb +16 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/passwords/edit.html.erb +16 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/passwords/new.html.erb +12 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/registrations/_fields.html.erb +16 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/registrations/edit.html.erb +28 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/registrations/new.html.erb +13 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/sessions/new.html.erb +17 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/devise/shared/_links.erb +25 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/layouts/_header.html.erb +19 -0
- data/lib/generators/chapter08_09/solutions/templates/app/views/layouts/application.html.erb +20 -0
- data/lib/generators/chapter10/begin/USAGE +24 -0
- data/lib/generators/chapter10/begin/begin_generator.rb +41 -0
- data/lib/generators/chapter10/begin/instructions.md +47 -0
- data/lib/generators/chapter10/begin/snippets/custom.css +12 -0
- data/lib/generators/chapter10/begin/snippets/factories.rb +10 -0
- data/lib/generators/chapter10/begin/templates/app/views/layouts/application.html.erb +21 -0
- data/lib/generators/chapter10/begin/templates/lib/tasks/sample_data.rake +24 -0
- data/lib/generators/chapter10/begin/templates/spec/controllers/users_controller_10_spec.rb +110 -0
- data/lib/generators/chapter10/begin/templates/spec/models/user_10_spec.rb +24 -0
- data/lib/generators/chapter10/solutions/USAGE +18 -0
- data/lib/generators/chapter10/solutions/snippets/migration_add_admin_to_users.rb +9 -0
- data/lib/generators/chapter10/solutions/solutions_generator.rb +32 -0
- data/lib/generators/chapter10/solutions/templates/app/controllers/users_controller.rb +28 -0
- data/lib/generators/chapter10/solutions/templates/app/views/users/_user.html.erb +8 -0
- data/lib/generators/chapter10/solutions/templates/app/views/users/index.html.erb +9 -0
- data/lib/generators/chapter11_1/begin/USAGE +24 -0
- data/lib/generators/chapter11_1/begin/begin_generator.rb +24 -0
- data/lib/generators/chapter11_1/begin/instructions.md +39 -0
- data/lib/generators/chapter11_1/begin/templates/lib/tasks/sample_data.rake +29 -0
- data/lib/generators/chapter11_1/begin/templates/spec/models/microposts_11_1_spec.rb +45 -0
- data/lib/generators/chapter11_1/begin/templates/spec/models/user_11_1_spec.rb +30 -0
- data/lib/generators/chapter11_1/solutions/USAGE +18 -0
- data/lib/generators/chapter11_1/solutions/snippets/migration_create_microposts.rb +17 -0
- data/lib/generators/chapter11_1/solutions/solutions_generator.rb +25 -0
- data/lib/generators/chapter11_1/solutions/templates/app/models/micropost.rb +10 -0
- data/lib/generators/chapter11_1/solutions/templates/app/models/user.rb +14 -0
- data/lib/generators/chapter11_1/solutions/templates/spec/factories.rb +16 -0
- data/lib/generators/chapter11_2/begin/USAGE +24 -0
- data/lib/generators/chapter11_2/begin/begin_generator.rb +30 -0
- data/lib/generators/chapter11_2/begin/instructions.md +35 -0
- data/lib/generators/chapter11_2/begin/snippets/custom.css +59 -0
- data/lib/generators/chapter11_2/begin/templates/app/views/users/show.html.erb +23 -0
- data/lib/generators/chapter11_2/begin/templates/spec/controllers/users_controller_11_2_spec.rb +31 -0
- data/lib/generators/chapter11_2/solutions/USAGE +18 -0
- data/lib/generators/chapter11_2/solutions/solutions_generator.rb +12 -0
- data/lib/generators/chapter11_2/solutions/templates/app/controllers/users_controller.rb +29 -0
- data/lib/generators/chapter11_2/solutions/templates/app/views/microposts/_micropost.html.erb +8 -0
- data/lib/generators/chapter11_2/solutions/templates/app/views/users/show.html.erb +23 -0
- data/lib/generators/chapter11_3/begin/USAGE +24 -0
- data/lib/generators/chapter11_3/begin/begin_generator.rb +24 -0
- data/lib/generators/chapter11_3/begin/instructions.md +80 -0
- data/lib/generators/chapter11_3/begin/templates/app/views/pages/home.html.erb +24 -0
- data/lib/generators/chapter11_3/begin/templates/app/views/shared/_feed.html.erb +6 -0
- data/lib/generators/chapter11_3/begin/templates/app/views/shared/_feed_item.html.erb +14 -0
- data/lib/generators/chapter11_3/begin/templates/app/views/shared/_micropost_form.html.erb +9 -0
- data/lib/generators/chapter11_3/begin/templates/app/views/shared/_user_info.html.erb +11 -0
- data/lib/generators/chapter11_3/begin/templates/spec/controllers/microposts_controllers_11_3_spec.rb +103 -0
- data/lib/generators/chapter11_3/begin/templates/spec/controllers/pages_controller_11_3_spec.rb +14 -0
- data/lib/generators/chapter11_3/begin/templates/spec/models/user_11_3_spec.rb +31 -0
- data/lib/generators/chapter11_3/begin/templates/spec/requests/micropost_11_3_spec.rb +41 -0
- data/lib/generators/chapter11_3/solutions/USAGE +18 -0
- data/lib/generators/chapter11_3/solutions/solutions_generator.rb +30 -0
- data/lib/generators/chapter11_3/solutions/templates/app/controllers/microposts_controller.rb +20 -0
- data/lib/generators/chapter11_3/solutions/templates/app/controllers/pages_controller.rb +22 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/microposts/_micropost.html.erb +15 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/pages/home.html.erb +24 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_error_messages.html.erb +13 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_feed.html.erb +6 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_feed_item.html.erb +21 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_micropost_form.html.erb +9 -0
- data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_user_info.html.erb +11 -0
- data/lib/tft_rails.rb +2 -0
- metadata +217 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2@rails3
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Copyright 2011 Wolfram Arnold
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
This work was sponsored by Marakana.
|
23
|
+
|
24
|
+
|
25
|
+
License and Copyright for the original RailsTutorial sources:
|
26
|
+
|
27
|
+
Copyright (c) 2010 Michael Hartl
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person
|
30
|
+
obtaining a copy of this software and associated documentation
|
31
|
+
files (the "Software"), to deal in the Software without
|
32
|
+
restriction, including without limitation the rights to use,
|
33
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
34
|
+
copies of the Software, and to permit persons to whom the
|
35
|
+
Software is furnished to do so, subject to the following
|
36
|
+
conditions:
|
37
|
+
|
38
|
+
The above copyright notice and this permission notice shall be
|
39
|
+
included in all copies or substantial portions of the Software.
|
40
|
+
|
41
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
42
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
43
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
44
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
45
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
46
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
47
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
48
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
49
|
+
/*
|
50
|
+
* ------------------------------------------------------------
|
51
|
+
* "THE BEERWARE LICENSE" (Revision 42):
|
52
|
+
* Michael Hartl wrote this code. As long as you retain this
|
53
|
+
* notice, you can do whatever you want with this stuff. If we
|
54
|
+
* meet someday, and you think this stuff is worth it, you can
|
55
|
+
* buy me a beer in return.
|
56
|
+
* ------------------------------------------------------------
|
57
|
+
*/
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
TFT Rails
|
2
|
+
=========
|
3
|
+
|
4
|
+
This project is a series of exercises for learning Rails, based on an adaptation of Michael Hartl's [RailsTutorial],
|
5
|
+
using the [Test-First Teaching][tft] philosophy that was originally [developed][tft_preso] by [Sarah Allen][sarah] and [Alex Chaffee][alex] and others.
|
6
|
+
This project has been sponsored by [Marakana] and was authored by Wolfram Arnold in collaboration with Alex Chaffee.
|
7
|
+
|
8
|
+
This project is a gem which provides a series of generators intended to be run on a bare-bones Rails 3 app. Each
|
9
|
+
generator provides a new set of tests (specs) corresponding to a given chapter in [RailsTutorial] and a set of
|
10
|
+
solutions.
|
11
|
+
|
12
|
+
The project was modified by Shereef Bishay for use at [Dev Bootcamp](devbootcamp.com)
|
13
|
+
|
14
|
+
Installation and Use
|
15
|
+
--------------------
|
16
|
+
|
17
|
+
To use, create a fresh Rails 3 project:
|
18
|
+
|
19
|
+
rails new sample_app
|
20
|
+
|
21
|
+
Add this gem to `Gemfile`:
|
22
|
+
|
23
|
+
gem 'tft_rails_dbc'
|
24
|
+
|
25
|
+
Run the first generator:
|
26
|
+
|
27
|
+
rails generate chapter07:begin
|
28
|
+
|
29
|
+
Run the specs
|
30
|
+
|
31
|
+
rake spec
|
32
|
+
|
33
|
+
Implement code to make the specs all pass. To compare to the solution, or to skip ahead, run:
|
34
|
+
|
35
|
+
rails generate chapter07:solutions
|
36
|
+
|
37
|
+
If you wrote your own code files that conflict with the solutions, you'll be prompted like so:
|
38
|
+
|
39
|
+
conflict app/controllers/application_controller.rb
|
40
|
+
Overwrite /home/wolfram/workspace/classes/ruby_rails/iterations/sample_app_tft/app/controllers/application_controller.rb? (enter "h" for help) [Ynaqdh]
|
41
|
+
|
42
|
+
Choose 'h' for a list of options, 'Y' for accepting the solution file as is, 'n' for leaving your own file in place, 'd' to view the difference between both.
|
43
|
+
|
44
|
+
As a matter of best practice, you should commit your solutions to git, then run the finish generator above, accept all conflicts with 'Y' and use git tools
|
45
|
+
to view the differences and change files selectively.
|
46
|
+
|
47
|
+
Then continue to the next chapters...
|
48
|
+
|
49
|
+
rails generate chapter08_09:begin
|
50
|
+
rails generate chapter08_09:solutions
|
51
|
+
rails generate chapter10:begin
|
52
|
+
rails generate chapter10:solutions
|
53
|
+
rails generate chapter11-1:begin
|
54
|
+
rails generate chapter11-1:solutions
|
55
|
+
rails generate chapter11-2:begin
|
56
|
+
rails generate chapter11-2:solutions
|
57
|
+
rails generate chapter11-3:begin
|
58
|
+
rails generate chapter11-3:solutions
|
59
|
+
|
60
|
+
Note that chapters are not exactly sequential. This is because some chapters in RailsTutorial have been skipped due to
|
61
|
+
the adaptations, see below.
|
62
|
+
|
63
|
+
Adapted how?
|
64
|
+
------------
|
65
|
+
|
66
|
+
The project is based on an adaptation of [RailsTutorial]. The main difference is that the [Devise gem][devise] was used
|
67
|
+
instead of the home-grown solution that RailsTutorial builds up. This was done for two reasons: (1) These exercises
|
68
|
+
are designed for a 3-day course preceded by a 2-day Ruby course. There is not enough time to cover a building up an
|
69
|
+
authentication solution from scratch, and for a general-purpose Rails class, the author views it as more important
|
70
|
+
to provide a full sweep through many Rails features than to focus on the specific intricacies of building an
|
71
|
+
authentication solution. (2) Authentication is a hard problem that shouldn't be taken lightly. RailsTutorial does
|
72
|
+
a wonderful job to illustrate many concepts for teaching, but it is no replacement for an industrial strength solution
|
73
|
+
that has been peer-reviewed by many experienced developers and is in use in many commercial applications. Devise is the
|
74
|
+
current industry standard solution and was used here.
|
75
|
+
|
76
|
+
|
77
|
+
Sponsors
|
78
|
+
--------
|
79
|
+
|
80
|
+
This project has been underwritten by [Marakana] and developed by Wolfram Arnold in collaboration with Alex Chaffee. It has been upgraded by Shereef Bishay
|
81
|
+
|
82
|
+
[RailsTutorial]: http://railstutorial.org "Rails Tutorial"
|
83
|
+
[tft]: http://testfirst.org/ "Test-First Teaching"
|
84
|
+
[tft_preso]: http://www.slideshare.net/sarah.allen/test-first-teaching "TFT Presentation by Sarah Allen and Alex Chaffee"
|
85
|
+
[sarah]: http://blazingcloud.net "Sarah Allen, Founder of Blazing Cloud"
|
86
|
+
[alex]: http://alexch.github.com/ "Alex Chaffee"
|
87
|
+
[shereef]: http://github.com/shereefb/ "Shereef Bishay"
|
88
|
+
[devise]: https://github.com/plataformatec/devise "Devise on Github"
|
89
|
+
[Marakana]: http://marakana.com "Marakana.com"
|
90
|
+
[DevBootcamp]: http://devbootcamp.com "DevBootcamp.com"
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
|
12
|
+
require 'rspec/core'
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
|
17
|
+
task :default => :spec
|
18
|
+
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'TftRails'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README.rdoc')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Description:
|
2
|
+
Begins Test-First Teaching exercises adapted from Chapter 07 of the RailsTutorial by Michael Hartl.
|
3
|
+
|
4
|
+
Chapter 07 is the first chapter covered, because the application built herein is an adaptation from
|
5
|
+
RailsTutorial and uses the Devise authentication gem, rather than the home-grown solution from RailsTutorial.
|
6
|
+
|
7
|
+
It is assumed that this generator is run in an freshly-created bare-bones Rails project.
|
8
|
+
|
9
|
+
Successive chapters are expected to be run sequentially. Each chapter's generators comes with a delta
|
10
|
+
to the next chapter, in two phase, the "begin" one will create tests, the "finish" one includes the solution files.
|
11
|
+
If all tests pass, the "finish" phase is optional.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
rails generate chapter07:begin
|
15
|
+
|
16
|
+
This copies new tests into the project, which are failing.
|
17
|
+
The student's task is to write code to make the test pass. The material covered by the tests is consistent
|
18
|
+
with Chapter 07 of the RailsTutorial.
|
19
|
+
|
20
|
+
When you're done, and all tests pass, or you just want to skip ahead, run:
|
21
|
+
|
22
|
+
rails generate chapter07:solutions
|
23
|
+
|
24
|
+
This will copy solutions files into the application tree. If you already have a solution file,
|
25
|
+
you'll be prompted whether you want to overwrite your file, see the difference, or keep your file.
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Chapter07
|
2
|
+
module Generators
|
3
|
+
class BeginGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
def copy_app_tree
|
7
|
+
directory(self.class.source_root, Rails.root, :force => true)
|
8
|
+
end
|
9
|
+
|
10
|
+
def insert_gitignore
|
11
|
+
dest = File.join(Rails.root,'.gitignore')
|
12
|
+
insert_into_file(dest, :before => /\Z/) do # insert before end
|
13
|
+
"\n.idea\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def augment_gemfile
|
18
|
+
gem 'devise'
|
19
|
+
gem 'gravatar_image_tag', '~> 1.0.0'
|
20
|
+
gem 'rspec-rails', :version => '~> 2.6.0', :group => :development
|
21
|
+
gem 'rspec', :version => '~> 2.6.0', :group => :test
|
22
|
+
gem 'webrat', :version => '~> 0.7.3', :group => :test
|
23
|
+
gem 'factory_girl_rails', :version => '~> 1.0', :group => :test
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_instructions
|
27
|
+
require 'rdiscount'
|
28
|
+
|
29
|
+
instr_md = File.expand_path('../instructions.md',self.class.source_root)
|
30
|
+
dest = File.join(Rails.root,'doc','chapter07.html')
|
31
|
+
copy_file(instr_md, dest, :force => true) do |content|
|
32
|
+
RDiscount.new(content).to_html
|
33
|
+
end
|
34
|
+
say_status('Note',"Now open file://#{dest} in your web browser for instructions", :cyan)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
RailsTutorial Chapter 07 Test-First Teaching Instructions
|
2
|
+
=========================================================
|
3
|
+
|
4
|
+
Running Specs
|
5
|
+
-------------
|
6
|
+
|
7
|
+
See the paragraphs below for more details on each exercise.
|
8
|
+
To run all spec files:
|
9
|
+
|
10
|
+
rake spec
|
11
|
+
|
12
|
+
To run just one file, you can also run, e.g.
|
13
|
+
|
14
|
+
rspec spec/controllers/pages_controller_spec.rb
|
15
|
+
|
16
|
+
Note: Before you run the specs for the very first time,
|
17
|
+
most likely you'll need to migrate your database with:
|
18
|
+
|
19
|
+
rake db:migrate
|
20
|
+
|
21
|
+
This will migrate the development database only. Your specs,
|
22
|
+
however, will use the test database. The `rake spec` command
|
23
|
+
automatically takes care of copying the latest schema from
|
24
|
+
the development database to the test database, thereby
|
25
|
+
migrating the test database as well.
|
26
|
+
|
27
|
+
This is not the case for the `rspec` command. You can run
|
28
|
+
`rake spec` once, or you can explicitly set up the test
|
29
|
+
database with the latest schema via: `rake db:test:prepare`
|
30
|
+
|
31
|
+
Static Pages
|
32
|
+
------------
|
33
|
+
|
34
|
+
The purpose of this section is completing the static pages,
|
35
|
+
such as About, Help, Home, etc.
|
36
|
+
|
37
|
+
The pages are currently in various stages of completion.
|
38
|
+
|
39
|
+
For some, the controller action is present, in
|
40
|
+
`PagesController`, for some it is missing. Some have
|
41
|
+
view templates in `app/views/pages`, others do not.
|
42
|
+
|
43
|
+
Some have route entries in `config/routes`, others do not.
|
44
|
+
|
45
|
+
Run the spec, `specs/controllers/pages_controller_spec.rb`
|
46
|
+
and watch carefully for the error message and look
|
47
|
+
at what each spec is asserting.
|
48
|
+
|
49
|
+
User Validation
|
50
|
+
---------------
|
51
|
+
|
52
|
+
Another purpose of this section are validations of the
|
53
|
+
User model. Run `specs/models/user_spec.rb` and
|
54
|
+
see what is failing. Review the presentation slides on
|
55
|
+
validation of inspiration.
|
56
|
+
|
57
|
+
Users Controller
|
58
|
+
----------------
|
59
|
+
|
60
|
+
This section also has tests on the `UsersController`'s
|
61
|
+
show action. It is in charge of displaying a given
|
62
|
+
user's info.
|
63
|
+
|
64
|
+
Currently, the view template exists, but contains placeholders.
|
65
|
+
Your task is to replace them with actual code such
|
66
|
+
that the tests pass.
|
67
|
+
|
68
|
+
Layouts
|
69
|
+
-------
|
70
|
+
|
71
|
+
Lastly, this section has tests against the navigation
|
72
|
+
links on the layout. This deals with the application
|
73
|
+
layout in `views/layouts/application.html.erb` and its
|
74
|
+
associated partials.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
# Include default devise modules. Others available are:
|
3
|
+
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
4
|
+
devise :database_authenticatable, :registerable,
|
5
|
+
:recoverable, :rememberable, :trackable, :validatable
|
6
|
+
|
7
|
+
# Setup accessible (or protected) attributes for your model
|
8
|
+
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
|
9
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<header>
|
2
|
+
<% logo = image_tag("logo.png", :alt => "Sample App", :class => "round") %>
|
3
|
+
<%= link_to logo, root_path %>
|
4
|
+
<nav class="round">
|
5
|
+
<ul>
|
6
|
+
<li><%= link_to "Home", root_path %></li>
|
7
|
+
<li><%= link_to "Sign in", '#' %></li>
|
8
|
+
</ul>
|
9
|
+
</nav>
|
10
|
+
</header>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!--[if lt IE 9]>
|
2
|
+
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
3
|
+
<![endif]-->
|
4
|
+
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
|
5
|
+
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
|
6
|
+
<!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->
|
7
|
+
<%= stylesheet_link_tag 'custom', :media => 'screen' %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= title %></title>
|
5
|
+
<%= csrf_meta_tag %>
|
6
|
+
<%= render 'layouts/stylesheets' %>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div class="container">
|
10
|
+
<%= render 'layouts/header' %>
|
11
|
+
<section class="round">
|
12
|
+
<%= yield %>
|
13
|
+
</section>
|
14
|
+
<%= render 'layouts/footer' %>
|
15
|
+
</div>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<h1>About Us</h1>
|
2
|
+
<p>
|
3
|
+
<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>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<table class="profile" summary="Profile information">
|
2
|
+
<tr>
|
3
|
+
<td class="main">
|
4
|
+
<h1>
|
5
|
+
User's gravatar image (hint: see users_helper.rb file)
|
6
|
+
and User's name here
|
7
|
+
</h1>
|
8
|
+
</td>
|
9
|
+
<td class="sidebar round">
|
10
|
+
<strong>Name</strong> User's name here
|
11
|
+
<br/>
|
12
|
+
<strong>URL</strong> Link to this page here
|
13
|
+
</td>
|
14
|
+
</tr>
|
15
|
+
</table>
|