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.
Files changed (159) hide show
  1. data/.gitignore +6 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE +57 -0
  5. data/README.md +90 -0
  6. data/Rakefile +25 -0
  7. data/lib/generators/chapter07/begin/USAGE +27 -0
  8. data/lib/generators/chapter07/begin/begin_generator.rb +39 -0
  9. data/lib/generators/chapter07/begin/instructions.md +74 -0
  10. data/lib/generators/chapter07/begin/templates/app/controllers/application_controller.rb +8 -0
  11. data/lib/generators/chapter07/begin/templates/app/controllers/pages_controller.rb +11 -0
  12. data/lib/generators/chapter07/begin/templates/app/controllers/users_controller.rb +3 -0
  13. data/lib/generators/chapter07/begin/templates/app/helpers/application_helper.rb +12 -0
  14. data/lib/generators/chapter07/begin/templates/app/helpers/pages_helper.rb +2 -0
  15. data/lib/generators/chapter07/begin/templates/app/helpers/users_helper.rb +7 -0
  16. data/lib/generators/chapter07/begin/templates/app/models/user.rb +9 -0
  17. data/lib/generators/chapter07/begin/templates/app/views/layouts/_footer.html.erb +9 -0
  18. data/lib/generators/chapter07/begin/templates/app/views/layouts/_header.html.erb +10 -0
  19. data/lib/generators/chapter07/begin/templates/app/views/layouts/_stylesheets.html.erb +7 -0
  20. data/lib/generators/chapter07/begin/templates/app/views/layouts/application.html.erb +17 -0
  21. data/lib/generators/chapter07/begin/templates/app/views/pages/about.html.erb +7 -0
  22. data/lib/generators/chapter07/begin/templates/app/views/pages/contact.html.erb +5 -0
  23. data/lib/generators/chapter07/begin/templates/app/views/pages/home.html.erb +7 -0
  24. data/lib/generators/chapter07/begin/templates/app/views/users/show.html.erb +15 -0
  25. data/lib/generators/chapter07/begin/templates/config/initializers/devise.rb +194 -0
  26. data/lib/generators/chapter07/begin/templates/config/locales/devise.en.yml +50 -0
  27. data/lib/generators/chapter07/begin/templates/config/routes.rb.tt +17 -0
  28. data/lib/generators/chapter07/begin/templates/db/migrate/20110608224650_devise_create_users.rb +29 -0
  29. data/lib/generators/chapter07/begin/templates/db/schema.rb +34 -0
  30. data/lib/generators/chapter07/begin/templates/public/images/logo.png +0 -0
  31. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/ie.css +36 -0
  32. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
  33. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
  34. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
  35. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
  36. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
  37. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
  38. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
  39. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
  40. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
  41. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
  42. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
  43. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
  44. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/lock.png +0 -0
  45. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  46. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
  47. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
  48. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
  49. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/link-icons/screen.css +42 -0
  50. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
  51. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/plugins/rtl/screen.css +110 -0
  52. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/print.css +29 -0
  53. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/screen.css +265 -0
  54. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/forms.css +82 -0
  55. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/grid.css +280 -0
  56. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/grid.png +0 -0
  57. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/ie.css +79 -0
  58. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/print.css +92 -0
  59. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/reset.css +65 -0
  60. data/lib/generators/chapter07/begin/templates/public/stylesheets/blueprint/src/typography.css +123 -0
  61. data/lib/generators/chapter07/begin/templates/public/stylesheets/custom.css +137 -0
  62. data/lib/generators/chapter07/begin/templates/spec/controllers/pages_controller_07_spec.rb +48 -0
  63. data/lib/generators/chapter07/begin/templates/spec/controllers/users_controller_07_spec.rb +38 -0
  64. data/lib/generators/chapter07/begin/templates/spec/factories.rb +9 -0
  65. data/lib/generators/chapter07/begin/templates/spec/models/user_07_spec.rb +38 -0
  66. data/lib/generators/chapter07/begin/templates/spec/requests/layout_links_07_spec.rb +44 -0
  67. data/lib/generators/chapter07/begin/templates/spec/spec_helper.rb +39 -0
  68. data/lib/generators/chapter07/solutions/USAGE +21 -0
  69. data/lib/generators/chapter07/solutions/solutions_generator.rb +23 -0
  70. data/lib/generators/chapter07/solutions/templates/app/controllers/pages_controller.rb +18 -0
  71. data/lib/generators/chapter07/solutions/templates/app/controllers/users_controller.rb +8 -0
  72. data/lib/generators/chapter07/solutions/templates/app/models/user.rb +11 -0
  73. data/lib/generators/chapter07/solutions/templates/app/views/layouts/_footer.html.erb +10 -0
  74. data/lib/generators/chapter07/solutions/templates/app/views/layouts/_header.html.erb +11 -0
  75. data/lib/generators/chapter07/solutions/templates/app/views/pages/help.html.erb +4 -0
  76. data/lib/generators/chapter07/solutions/templates/app/views/pages/home.html.erb +7 -0
  77. data/lib/generators/chapter07/solutions/templates/app/views/users/show.html.erb +15 -0
  78. data/lib/generators/chapter08_09/begin/USAGE +24 -0
  79. data/lib/generators/chapter08_09/begin/begin_generator.rb +29 -0
  80. data/lib/generators/chapter08_09/begin/instructions.md +65 -0
  81. data/lib/generators/chapter08_09/begin/snippets/custom.css +49 -0
  82. data/lib/generators/chapter08_09/begin/templates/spec/controllers/devise/registrations_controller_08_spec.rb +83 -0
  83. data/lib/generators/chapter08_09/begin/templates/spec/requests/layout_links_09_spec.rb +35 -0
  84. data/lib/generators/chapter08_09/begin/templates/spec/requests/users_signup_08_spec.rb +36 -0
  85. data/lib/generators/chapter08_09/solutions/USAGE +18 -0
  86. data/lib/generators/chapter08_09/solutions/solutions_generator.rb +12 -0
  87. data/lib/generators/chapter08_09/solutions/templates/app/helpers/application_helper.rb +16 -0
  88. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/passwords/edit.html.erb +16 -0
  89. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/passwords/new.html.erb +12 -0
  90. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/registrations/_fields.html.erb +16 -0
  91. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/registrations/edit.html.erb +28 -0
  92. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/registrations/new.html.erb +13 -0
  93. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/sessions/new.html.erb +17 -0
  94. data/lib/generators/chapter08_09/solutions/templates/app/views/devise/shared/_links.erb +25 -0
  95. data/lib/generators/chapter08_09/solutions/templates/app/views/layouts/_header.html.erb +19 -0
  96. data/lib/generators/chapter08_09/solutions/templates/app/views/layouts/application.html.erb +20 -0
  97. data/lib/generators/chapter10/begin/USAGE +24 -0
  98. data/lib/generators/chapter10/begin/begin_generator.rb +41 -0
  99. data/lib/generators/chapter10/begin/instructions.md +47 -0
  100. data/lib/generators/chapter10/begin/snippets/custom.css +12 -0
  101. data/lib/generators/chapter10/begin/snippets/factories.rb +10 -0
  102. data/lib/generators/chapter10/begin/templates/app/views/layouts/application.html.erb +21 -0
  103. data/lib/generators/chapter10/begin/templates/lib/tasks/sample_data.rake +24 -0
  104. data/lib/generators/chapter10/begin/templates/spec/controllers/users_controller_10_spec.rb +110 -0
  105. data/lib/generators/chapter10/begin/templates/spec/models/user_10_spec.rb +24 -0
  106. data/lib/generators/chapter10/solutions/USAGE +18 -0
  107. data/lib/generators/chapter10/solutions/snippets/migration_add_admin_to_users.rb +9 -0
  108. data/lib/generators/chapter10/solutions/solutions_generator.rb +32 -0
  109. data/lib/generators/chapter10/solutions/templates/app/controllers/users_controller.rb +28 -0
  110. data/lib/generators/chapter10/solutions/templates/app/views/users/_user.html.erb +8 -0
  111. data/lib/generators/chapter10/solutions/templates/app/views/users/index.html.erb +9 -0
  112. data/lib/generators/chapter11_1/begin/USAGE +24 -0
  113. data/lib/generators/chapter11_1/begin/begin_generator.rb +24 -0
  114. data/lib/generators/chapter11_1/begin/instructions.md +39 -0
  115. data/lib/generators/chapter11_1/begin/templates/lib/tasks/sample_data.rake +29 -0
  116. data/lib/generators/chapter11_1/begin/templates/spec/models/microposts_11_1_spec.rb +45 -0
  117. data/lib/generators/chapter11_1/begin/templates/spec/models/user_11_1_spec.rb +30 -0
  118. data/lib/generators/chapter11_1/solutions/USAGE +18 -0
  119. data/lib/generators/chapter11_1/solutions/snippets/migration_create_microposts.rb +17 -0
  120. data/lib/generators/chapter11_1/solutions/solutions_generator.rb +25 -0
  121. data/lib/generators/chapter11_1/solutions/templates/app/models/micropost.rb +10 -0
  122. data/lib/generators/chapter11_1/solutions/templates/app/models/user.rb +14 -0
  123. data/lib/generators/chapter11_1/solutions/templates/spec/factories.rb +16 -0
  124. data/lib/generators/chapter11_2/begin/USAGE +24 -0
  125. data/lib/generators/chapter11_2/begin/begin_generator.rb +30 -0
  126. data/lib/generators/chapter11_2/begin/instructions.md +35 -0
  127. data/lib/generators/chapter11_2/begin/snippets/custom.css +59 -0
  128. data/lib/generators/chapter11_2/begin/templates/app/views/users/show.html.erb +23 -0
  129. data/lib/generators/chapter11_2/begin/templates/spec/controllers/users_controller_11_2_spec.rb +31 -0
  130. data/lib/generators/chapter11_2/solutions/USAGE +18 -0
  131. data/lib/generators/chapter11_2/solutions/solutions_generator.rb +12 -0
  132. data/lib/generators/chapter11_2/solutions/templates/app/controllers/users_controller.rb +29 -0
  133. data/lib/generators/chapter11_2/solutions/templates/app/views/microposts/_micropost.html.erb +8 -0
  134. data/lib/generators/chapter11_2/solutions/templates/app/views/users/show.html.erb +23 -0
  135. data/lib/generators/chapter11_3/begin/USAGE +24 -0
  136. data/lib/generators/chapter11_3/begin/begin_generator.rb +24 -0
  137. data/lib/generators/chapter11_3/begin/instructions.md +80 -0
  138. data/lib/generators/chapter11_3/begin/templates/app/views/pages/home.html.erb +24 -0
  139. data/lib/generators/chapter11_3/begin/templates/app/views/shared/_feed.html.erb +6 -0
  140. data/lib/generators/chapter11_3/begin/templates/app/views/shared/_feed_item.html.erb +14 -0
  141. data/lib/generators/chapter11_3/begin/templates/app/views/shared/_micropost_form.html.erb +9 -0
  142. data/lib/generators/chapter11_3/begin/templates/app/views/shared/_user_info.html.erb +11 -0
  143. data/lib/generators/chapter11_3/begin/templates/spec/controllers/microposts_controllers_11_3_spec.rb +103 -0
  144. data/lib/generators/chapter11_3/begin/templates/spec/controllers/pages_controller_11_3_spec.rb +14 -0
  145. data/lib/generators/chapter11_3/begin/templates/spec/models/user_11_3_spec.rb +31 -0
  146. data/lib/generators/chapter11_3/begin/templates/spec/requests/micropost_11_3_spec.rb +41 -0
  147. data/lib/generators/chapter11_3/solutions/USAGE +18 -0
  148. data/lib/generators/chapter11_3/solutions/solutions_generator.rb +30 -0
  149. data/lib/generators/chapter11_3/solutions/templates/app/controllers/microposts_controller.rb +20 -0
  150. data/lib/generators/chapter11_3/solutions/templates/app/controllers/pages_controller.rb +22 -0
  151. data/lib/generators/chapter11_3/solutions/templates/app/views/microposts/_micropost.html.erb +15 -0
  152. data/lib/generators/chapter11_3/solutions/templates/app/views/pages/home.html.erb +24 -0
  153. data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_error_messages.html.erb +13 -0
  154. data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_feed.html.erb +6 -0
  155. data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_feed_item.html.erb +21 -0
  156. data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_micropost_form.html.erb +9 -0
  157. data/lib/generators/chapter11_3/solutions/templates/app/views/shared/_user_info.html.erb +11 -0
  158. data/lib/tft_rails.rb +2 -0
  159. metadata +217 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ *.gem
5
+ Gemfile.lock
6
+ .idea
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@rails3
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "3.0.9"
4
+ gem "sqlite3"
5
+
6
+ gem "rspec-rails", "~> 2.6.0"
7
+
8
+ gemspec
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,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ # This tells Devise where to re-direct to after successful sign up or sign in
5
+ def after_sign_in_path_for(user)
6
+ user_path(user.id)
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class PagesController < ApplicationController
2
+ def home
3
+ end
4
+
5
+ def contact
6
+ end
7
+
8
+ def about
9
+ end
10
+
11
+ end
@@ -0,0 +1,3 @@
1
+ class UsersController < ApplicationController
2
+
3
+ end
@@ -0,0 +1,12 @@
1
+ module ApplicationHelper
2
+
3
+ def title
4
+ base_title = "Ruby on Rails Tutorial Sample App"
5
+ if @title.nil?
6
+ base_title
7
+ else
8
+ "#{base_title} | #{@title}"
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,2 @@
1
+ module PagesHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ module UsersHelper
2
+ def gravatar_for(user, options = { :size => 50 })
3
+ gravatar_image_tag(user.email.downcase, :alt => user.name,
4
+ :class => 'gravatar',
5
+ :gravatar => options)
6
+ end
7
+ end
@@ -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,9 @@
1
+ <footer>
2
+ <nav class="round">
3
+ <ul>
4
+ <li><%= link_to "Contact", contact_path %></li>
5
+ <li><a href="http://news.railstutorial.org/">News</a></li>
6
+ <li><a href="http://www.railstutorial.org/">Rails Tutorial</a></li>
7
+ </ul>
8
+ </nav>
9
+ </footer>
@@ -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,5 @@
1
+ <h1>Contact</h1>
2
+ <p>
3
+ Contact Ruby on Rails Tutorial about the sample app at the
4
+ <a href="http://railstutorial.org/feedback">feedback page</a>.
5
+ </p>
@@ -0,0 +1,7 @@
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>
7
+ <%= link_to "Sign up now!", '#', :class => "signup_button round" %>
@@ -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>