Permalink
Browse files

basic posts page from first screencast

  • Loading branch information...
woody2shoes
woody2shoes committed Jun 22, 2010
1 parent e5dc2d4 commit 10df982988a74cf3f969964c7bdeb2f16a432a91
Showing with 763 additions and 291 deletions.
  1. +12 −2 Gemfile
  2. +141 −0 Gemfile.lock
  3. +6 −0 app/controllers/posts_controller.rb
  4. +2 −0 app/helpers/posts_helper.rb
  5. +3 −0 app/models/post.rb
  6. +2 −0 app/models/user.rb
  7. +5 −0 app/views/posts/_post.html.erb
  8. +2 −0 app/views/posts/index.html.erb
  9. +21 −0 capybara-20100621234332.html
  10. +21 −0 capybara-20100621234450.html
  11. +24 −0 capybara-20100621234541.html
  12. +8 −0 config/cucumber.yml
  13. +14 −9 config/database.yml
  14. +2 −0 config/environments/development.rb
  15. +3 −1 config/routes.rb
  16. +16 −0 db/migrate/20100622053627_create_posts.rb
  17. +13 −0 db/migrate/20100622053648_create_users.rb
  18. +29 −0 db/schema.rb
  19. +16 −0 features/front_page.feature
  20. +23 −0 features/step_definitions/front_page_steps.rb
  21. +219 −0 features/step_definitions/web_steps.rb
  22. +58 −0 features/support/env.rb
  23. +33 −0 features/support/paths.rb
  24. +53 −0 lib/tasks/cucumber.rake
  25. +0 −279 public/index.html
  26. +10 −0 script/cucumber
  27. +12 −0 spec/controllers/posts_controller_spec.rb
  28. +5 −0 spec/models/post_spec.rb
  29. +5 −0 spec/models/user_spec.rb
  30. +5 −0 spec/views/posts/index.html.erb_spec.rb
  31. BIN vendor/cache/abstract-1.0.0.gem
  32. BIN vendor/cache/actionmailer-3.0.0.beta4.gem
  33. BIN vendor/cache/actionpack-3.0.0.beta4.gem
  34. BIN vendor/cache/activemodel-3.0.0.beta4.gem
  35. BIN vendor/cache/activerecord-3.0.0.beta4.gem
  36. BIN vendor/cache/activeresource-3.0.0.beta4.gem
  37. BIN vendor/cache/activesupport-3.0.0.beta4.gem
  38. BIN vendor/cache/arel-0.4.0.gem
  39. BIN vendor/cache/builder-2.1.2.gem
  40. BIN vendor/cache/bundler-0.9.26.gem
  41. BIN vendor/cache/capybara-0.3.8.gem
  42. BIN vendor/cache/configuration-1.1.0.gem
  43. BIN vendor/cache/cucumber-0.8.3.gem
  44. BIN vendor/cache/cucumber-rails-0.3.2.gem
  45. BIN vendor/cache/culerity-0.2.10.gem
  46. BIN vendor/cache/database_cleaner-0.5.2.gem
  47. BIN vendor/cache/diff-lcs-1.1.2.gem
  48. BIN vendor/cache/erubis-2.6.5.gem
  49. BIN vendor/cache/ffi-0.6.3.gem
  50. BIN vendor/cache/gherkin-2.0.2.gem
  51. BIN vendor/cache/i18n-0.4.1.gem
  52. BIN vendor/cache/json_pure-1.4.3.gem
  53. BIN vendor/cache/launchy-0.3.5.gem
  54. BIN vendor/cache/mail-2.2.5.gem
  55. BIN vendor/cache/mime-types-1.16.gem
  56. BIN vendor/cache/mysql-2.8.1.gem
  57. BIN vendor/cache/nokogiri-1.4.2.gem
  58. BIN vendor/cache/polyglot-0.3.1.gem
  59. BIN vendor/cache/rack-1.1.0.gem
  60. BIN vendor/cache/rack-mount-0.6.6.gem
  61. BIN vendor/cache/rack-test-0.5.4.gem
  62. BIN vendor/cache/rails-3.0.0.beta4.gem
  63. BIN vendor/cache/railties-3.0.0.beta4.gem
  64. BIN vendor/cache/rake-0.8.7.gem
  65. BIN vendor/cache/rspec-2.0.0.beta.12.gem
  66. BIN vendor/cache/rspec-core-2.0.0.beta.12.gem
  67. BIN vendor/cache/rspec-expectations-2.0.0.beta.12.gem
  68. BIN vendor/cache/rspec-mocks-2.0.0.beta.12.gem
  69. BIN vendor/cache/rspec-rails-2.0.0.beta.12.gem
  70. BIN vendor/cache/selenium-webdriver-0.0.24.gem
  71. BIN vendor/cache/spork-0.8.4.gem
  72. BIN vendor/cache/term-ansicolor-1.0.5.gem
  73. BIN vendor/cache/thor-0.13.6.gem
  74. BIN vendor/cache/treetop-1.4.8.gem
  75. BIN vendor/cache/trollop-1.16.2.gem
  76. BIN vendor/cache/tzinfo-0.3.22.gem
  77. BIN vendor/cache/webrat-0.7.1.gem
View
14 Gemfile
@@ -1,11 +1,21 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.0.beta3'
+gem 'rails', '3.0.0.beta4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3-ruby', :require => 'sqlite3'
+gem 'mysql'
+
+# Cucumber + Rspec = Awesome
+gem 'capybara'
+gem 'database_cleaner'
+gem 'cucumber-rails'
+gem 'cucumber'
+gem 'rspec', '2.0.0.beta.12'
+gem 'rspec-rails', '2.0.0.beta.12'
+gem 'spork'
+gem 'launchy'
# Use unicorn as the web server
# gem 'unicorn'
View
@@ -0,0 +1,141 @@
+---
+dependencies:
+ spork:
+ group:
+ - :default
+ version: ">= 0"
+ rails:
+ group:
+ - :default
+ version: = 3.0.0.beta4
+ mysql:
+ group:
+ - :default
+ version: ">= 0"
+ rspec:
+ group:
+ - :default
+ version: = 2.0.0.beta.12
+ rspec-rails:
+ group:
+ - :default
+ version: = 2.0.0.beta.12
+ database_cleaner:
+ group:
+ - :default
+ version: ">= 0"
+ cucumber-rails:
+ group:
+ - :default
+ version: ">= 0"
+ cucumber:
+ group:
+ - :default
+ version: ">= 0"
+ launchy:
+ group:
+ - :default
+ version: ">= 0"
+ capybara:
+ group:
+ - :default
+ version: ">= 0"
+specs:
+- rake:
+ version: 0.8.7
+- abstract:
+ version: 1.0.0
+- activesupport:
+ version: 3.0.0.beta4
+- builder:
+ version: 2.1.2
+- i18n:
+ version: 0.4.1
+- activemodel:
+ version: 3.0.0.beta4
+- erubis:
+ version: 2.6.5
+- rack:
+ version: 1.1.0
+- rack-mount:
+ version: 0.6.6
+- rack-test:
+ version: 0.5.4
+- tzinfo:
+ version: 0.3.22
+- actionpack:
+ version: 3.0.0.beta4
+- mime-types:
+ version: "1.16"
+- polyglot:
+ version: 0.3.1
+- treetop:
+ version: 1.4.8
+- mail:
+ version: 2.2.5
+- actionmailer:
+ version: 3.0.0.beta4
+- arel:
+ version: 0.4.0
+- activerecord:
+ version: 3.0.0.beta4
+- activeresource:
+ version: 3.0.0.beta4
+- bundler:
+ version: 0.9.26
+- culerity:
+ version: 0.2.10
+- nokogiri:
+ version: 1.4.2
+- ffi:
+ version: 0.6.3
+- json_pure:
+ version: 1.4.3
+- selenium-webdriver:
+ version: 0.0.24
+- capybara:
+ version: 0.3.8
+- configuration:
+ version: 1.1.0
+- diff-lcs:
+ version: 1.1.2
+- trollop:
+ version: 1.16.2
+- gherkin:
+ version: 2.0.2
+- term-ansicolor:
+ version: 1.0.5
+- cucumber:
+ version: 0.8.3
+- cucumber-rails:
+ version: 0.3.2
+- database_cleaner:
+ version: 0.5.2
+- launchy:
+ version: 0.3.5
+- mysql:
+ version: 2.8.1
+- thor:
+ version: 0.13.6
+- railties:
+ version: 3.0.0.beta4
+- rails:
+ version: 3.0.0.beta4
+- rspec-core:
+ version: 2.0.0.beta.12
+- rspec-expectations:
+ version: 2.0.0.beta.12
+- rspec-mocks:
+ version: 2.0.0.beta.12
+- rspec:
+ version: 2.0.0.beta.12
+- webrat:
+ version: 0.7.1
+- rspec-rails:
+ version: 2.0.0.beta.12
+- spork:
+ version: 0.8.4
+hash: 9ed74a6df607361146b278be6dd4ec070c613c78
+sources:
+- Rubygems:
+ uri: http://rubygems.org
@@ -0,0 +1,6 @@
+class PostsController < ApplicationController
+ def index
+ @posts = Post.all
+ end
+
+end
@@ -0,0 +1,2 @@
+module PostsHelper
+end
View
@@ -0,0 +1,3 @@
+class Post < ActiveRecord::Base
+ belongs_to :author, :class_name => "User"
+end
View
@@ -0,0 +1,2 @@
+class User < ActiveRecord::Base
+end
@@ -0,0 +1,5 @@
+<h2><%= post.title %></h2>
+<div><span class="author">by <%= post.author.name %></span> <span class="published_on">on <%= post.published_on.strftime("%b %d, %Y") %></span></div>
+<p class="post_body">
+ <%= post.body %>
+</p>
@@ -0,0 +1,2 @@
+<h1>Posts</h1>
+<%= render :partial => "post", :collection => @posts %>
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Rpress</title>
+
+ <script src="/Users/chuck/tmtc/rpress/public/javascripts/prototype.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/effects.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/dragdrop.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/controls.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/rails.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/application.js?1277183900" type="text/javascript"></script>
+
+</head>
+<body>
+
+<h1>Posts</h1>
+<h2>My Post</h2>
+
+
+</body>
+</html>
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Rpress</title>
+
+ <script src="/Users/chuck/tmtc/rpress/public/javascripts/prototype.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/effects.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/dragdrop.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/controls.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/rails.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/application.js?1277183900" type="text/javascript"></script>
+
+</head>
+<body>
+
+<h1>Posts</h1>
+<h2>My Post</h2>
+
+
+</body>
+</html>
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Rpress</title>
+
+ <script src="/Users/chuck/tmtc/rpress/public/javascripts/prototype.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/effects.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/dragdrop.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/controls.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/rails.js?1277183900" type="text/javascript"></script>
+<script src="/Users/chuck/tmtc/rpress/public/javascripts/application.js?1277183900" type="text/javascript"></script>
+
+</head>
+<body>
+
+<h1>Posts</h1>
+<h2>My Post</h2>
+<p class="post_body">
+ This is my post. Back off!!!
+</p>
+
+
+</body>
+</html>
View
@@ -0,0 +1,8 @@
+<%
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
+%>
+default: <%= std_opts %> features
+wip: --tags @wip:3 --wip features
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
@@ -1,22 +1,27 @@
-# SQLite version 3.x
-# gem install sqlite3-ruby (not necessary on OS X Leopard)
+
development:
- adapter: sqlite3
- database: db/development.sqlite3
+ adapter: mysql
+ database: rpress
+ username: root
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
-test:
- adapter: sqlite3
- database: db/test.sqlite3
+test: &test
+ adapter: mysql
+ database: rpress_test
+ username: root
pool: 5
timeout: 5000
production:
- adapter: sqlite3
- database: db/production.sqlite3
+ adapter: mysql
+ database: rpress_prod
+ username: root
pool: 5
timeout: 5000
+
+cucumber:
+ <<: *test
@@ -17,3 +17,5 @@
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
end
+
+APP_URL = "http://localhost:3000/"
View
@@ -1,4 +1,6 @@
Rpress::Application.routes.draw do |map|
+ get "posts/index"
+
# The priority is based upon order of creation:
# first created -> highest priority.
@@ -48,7 +50,7 @@
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
- # root :to => "welcome#index"
+ root :to => "posts#index"
# See how all your routes lay out with "rake routes"
@@ -0,0 +1,16 @@
+class CreatePosts < ActiveRecord::Migration
+ def self.up
+ create_table :posts do |t|
+ t.string :title
+ t.text :body
+ t.integer :author_id
+ t.date :published_on
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :posts
+ end
+end
@@ -0,0 +1,13 @@
+class CreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
View
@@ -0,0 +1,29 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20100622053648) do
+
+ create_table "posts", :force => true do |t|
+ t.string "title"
+ t.text "body"
+ t.integer "author_id"
+ t.date "published_on"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "users", :force => true do |t|
+ t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
Oops, something went wrong.

0 comments on commit 10df982

Please sign in to comment.