Create a simple test application; run the provided functional tests.
ruby -rubygems /home/rubys/git/rails/bin/rails new testapp
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/views/layouts/application.html.erb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/models
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/test.rb
create config/environments/production.rb
create config/environments/development.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/session_store.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create log
create log/server.log
create log/production.log
create log/development.log
create log/test.log
create public
create public/404.html
create public/index.html
create public/favicon.ico
create public/422.html
create public/500.html
create public/robots.txt
create public/images
create public/images/rails.png
create public/stylesheets
create public/stylesheets/.gitkeep
create public/javascripts
create public/javascripts/prototype.js
create public/javascripts/controls.js
create public/javascripts/rails.js
create public/javascripts/application.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create script
create script/rails
create test
create test/performance/browsing_test.rb
create test/test_helper.rb
create test/fixtures
create test/unit
create test/functional
create test/integration
create tmp
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create vendor/plugins
create vendor/plugins/.gitkeep
bundle install
Using rake (0.8.7) from bundler gems
Using abstract (1.0.0) from bundler gems
Using activesupport (3.0.0.beta3) from source code at /home/rubys/git/rails
Using builder (2.1.2) from bundler gems
Using i18n (0.4.1) from bundler gems
Using activemodel (3.0.0.beta3) from source code at /home/rubys/git/rails
Using erubis (2.6.5) from bundler gems
Using rack (1.1.0) from bundler gems
Using rack-mount (0.6.3) from bundler gems
Using rack-test (0.5.4) from bundler gems
Using tzinfo (0.3.22) from bundler gems
Using actionpack (3.0.0.beta3) from source code at /home/rubys/git/rails
Using mime-types (1.16) from bundler gems
Using polyglot (0.3.1) from bundler gems
Using treetop (1.4.8) from bundler gems
Using mail (2.2.1) from bundler gems
Using actionmailer (3.0.0.beta3) from source code at /home/rubys/git/rails
Using arel (0.3.3) from bundler gems
Using activerecord (3.0.0.beta3) from source code at /home/rubys/git/rails
Using activeresource (3.0.0.beta3) from source code at /home/rubys/git/rails
Using bundler (0.9.25) from bundler gems
Using thor (0.13.6) from bundler gems
Using railties (3.0.0.beta3) from source code at /home/rubys/git/rails
Using rails (3.0.0.beta3) from source code at /home/rubys/git/rails
Using sqlite3-ruby (1.3.0) from bundler gems Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
rails generate scaffold product title:string
invoke active_record
create db/migrate/20100607141349_create_products.rb
create app/models/product.rb
invoke test_unit
create test/unit/product_test.rb
create test/fixtures/products.yml
route resources :products
invoke scaffold_controller
create app/controllers/products_controller.rb
invoke erb
create app/views/products
create app/views/products/index.html.erb
create app/views/products/edit.html.erb
create app/views/products/show.html.erb
create app/views/products/new.html.erb
create app/views/products/_form.html.erb
invoke test_unit
create test/functional/products_controller_test.rb
invoke helper
create app/helpers/products_helper.rb
invoke test_unit
create test/unit/helpers/products_helper_test.rb
invoke stylesheets
create public/stylesheets/scaffold.css
rake db:migrate
mv 20100607141349_create_products.rb 20100301000001_create_products.rb
(in /home/rubys/tmp/work-192/testapp)
== CreateProducts: migrating =================================================
-- create_table(:products)
-> 0.0011s
== CreateProducts: migrated (0.0013s) ========================================
rake test:functionals
(in /home/rubys/tmp/work-192/testapp)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-r28191/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.299584 seconds.
7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 16519
Create a test using XHR
edit test/functional/products_controller_test.rb
require 'test_helper'
class ProductsControllerTest < ActionController::TestCase
setup do
@product = products(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:products)
end
test "should get new" do
get :new
assert_response :success
end
test "should create product" do
assert_difference('Product.count') do
post :create, :product => @product.attributes
end
assert_redirected_to product_path(assigns(:product))
end
test "should show product" do
get :show, :id => @product.to_param
assert_response :success
end
test "should get edit" do
get :edit, :id => @product.to_param
assert_response :success
end
test "should update product" do
put :update, :id => @product.to_param, :product => @product.attributes
assert_redirected_to product_path(assigns(:product))
end
test "should destroy product" do
assert_difference('Product.count', -1) do
delete :destroy, :id => @product.to_param
end
assert_redirected_to products_path
end
test "should create line_item via XHR" do
assert_difference('Product.count', +1) do
xhr :post, :create, :product_title => 'Lorem Ipsum'
end
end
end
Rerun the tests
rake test:functionals
(in /home/rubys/tmp/work-192/testapp)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-r28191/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........
Finished in 0.263162 seconds.
8 tests, 11 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 3741
Add js to the response formats for create
edit app/controllers/products_controller.rb
class ProductsController < ApplicationController
# GET /products
# GET /products.xml
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @products }
end
end
# GET /products/1
# GET /products/1.xml
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @product }
end
end
# GET /products/new
# GET /products/new.xml
def new
@product = Product.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @product }
end
end
# GET /products/1/edit
def edit
@product = Product.find(params[:id])
end
# POST /products
# POST /products.xml
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
format.html { redirect_to(@product, :notice => 'Product was successfully created.') }
format.js
format.xml { render :xml => @product, :status => :created, :location => @product }
else
format.html { render :action => "new" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
# PUT /products/1
# PUT /products/1.xml
def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /products/1
# DELETE /products/1.xml
def destroy
@product = Product.find(params[:id])
@product.destroy
respond_to do |format|
format.html { redirect_to(products_url) }
format.xml { head :ok }
end
end
end
Create a rjs file with a call to replace_html with a dummy id
edit app/views/products/create.js.rjs
page.replace_html('id', render(@product))
create an empty partial
edit app/views/products/_product.html.erb
<!-- this page intentionally left blank -->
Rerun functional tests
rake test:functionals
(in /home/rubys/tmp/work-192/testapp)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-r28191/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
E.......
Finished in 0.289917 seconds.
1) Error:
test_should_create_line_item_via_XHR(ProductsControllerTest):
ActionView::Template::Error: Missing partial products/product with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:js], :locale=>[:en, :en]} in view paths "/home/rubys/tmp/work-192/testapp/app/views"
/home/rubys/git/rails/actionpack/lib/action_view/paths.rb:14:in `find'
/home/rubys/git/rails/actionpack/lib/action_view/lookup_context.rb:79:in `find'
/home/rubys/git/rails/actionpack/lib/action_view/base.rb:186:in `find_template'
/home/rubys/git/rails/actionpack/lib/action_view/render/partials.rb:310:in `find_template'
/home/rubys/git/rails/actionpack/lib/action_view/render/partials.rb:211:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/render/partials.rb:332:in `_render_partial'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:30:in `render'
/home/rubys/tmp/work-192/testapp/app/views/products/create.js.rjs:1:in `block in _render_template__3686904183303043057_16097680_345557949844795282'
/home/rubys/git/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:154:in `instance_exec'
/home/rubys/git/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:154:in `block in initialize'
/home/rubys/git/rails/actionpack/lib/action_view/helpers/capture_helper.rb:169:in `with_output_buffer'
/home/rubys/git/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:153:in `initialize'
/home/rubys/git/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:584:in `new'
/home/rubys/git/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:584:in `update_page'
/home/rubys/tmp/work-192/testapp/app/views/products/create.js.rjs:1:in `_render_template__3686904183303043057_16097680_345557949844795282'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:134:in `block in render'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:48:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:126:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:58:in `block in _render_template'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:48:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:55:in `_render_template'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:25:in `render'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:114:in `_render_template'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:108:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/renderers.rb:47:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:101:in `render_to_string'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:92:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:17:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:39:in `block (2 levels) in render'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
8 tests, 10 assertions, 0 failures, 1 errors, 0 skips
Test run options: --seed 55871
rake aborted!
Command failed with status (1): [/home/rubys/.rvm/rubies/ruby-1.9.2-r28191/...]
(See full trace by running task with --trace)
</8 tests, 11 assertions, 0 failures, 0 errors/> expected but was <"(in /home/rubys/tmp/work-192/testapp)">. Traceback: /home/rubys/tmp/rjs_render_test.rb:57:in `block (2 levels) in <class:RjsRenderTest>' /home/rubys/git/gorp/lib/gorp/test.rb:148:in `call' /home/rubys/git/gorp/lib/gorp/test.rb:148:in `block (2 levels) in <class:TestCase>' /home/rubys/tmp/rjs_render_test.rb:56:in `block in <class:RjsRenderTest>'
Mon, 07 Jun 2010 14:14:09 GMT
/home/rubys/.rvm/rubies/ruby-1.9.2-r28191/bin/ruby -v
ruby 1.9.2dev (2010-06-06 revision 28191) [x86_64-linux]
gem -v
1.3.7
bundle show
Gems included by the bundle:
* abstract (1.0.0)
* actionmailer (3.0.0.beta3)
* actionpack (3.0.0.beta3)
* activemodel (3.0.0.beta3)
* activerecord (3.0.0.beta3)
* activeresource (3.0.0.beta3)
* activesupport (3.0.0.beta3)
* arel (0.3.3)
* builder (2.1.2)
* bundler (0.9.25)
* erubis (2.6.5)
* i18n (0.4.1)
* mail (2.2.1)
* mime-types (1.16)
* polyglot (0.3.1)
* rack (1.1.0)
* rack-mount (0.6.3)
* rack-test (0.5.4)
* rails (3.0.0.beta3 9e065c)
* railties (3.0.0.beta3)
* rake (0.8.7)
* sqlite3-ruby (1.3.0)
* thor (0.13.6)
* treetop (1.4.8)
* tzinfo (0.3.22)
rake about
(in /home/rubys/tmp/work-192/testapp)
About your application's environment
Ruby version 1.9.2 (x86_64-linux)
RubyGems version 1.3.7
Rack version 1.1
Rails version 3.0.0.beta3
Active Record version 3.0.0.beta3
Action Pack version 3.0.0.beta3
Active Resource version 3.0.0.beta3
Action Mailer version 3.0.0.beta3
Active Support version 3.0.0.beta3
Application root /home/rubys/tmp/work-192/testapp
Environment development
git log -1
commit 9e065c6bc175621ad30a416c8c4345f95ce3c264
Merge: 0dbc732 1a8f784
Author: Xavier Noria <fxn@hashref.com>
Date: Mon Jun 7 15:44:57 2010 +0200
Merge remote branch 'rails/master'