Skip to content
Browse files

Add demos controller and functional/integration test.

  • Loading branch information...
1 parent 30f6b44 commit 77e0c679ba6522e852b989fe15932efc26566b2b @metaskills committed May 11, 2011
View
6 app/controllers/demos_controller.rb
@@ -0,0 +1,6 @@
+class DemosController < ApplicationController
+
+ def index
+ end
+
+end
View
2 app/helpers/demos_helper.rb
@@ -0,0 +1,2 @@
+module DemosHelper
+end
View
6 app/views/demos/index.html.erb
@@ -0,0 +1,6 @@
+
+<h1 id="demoIndex">Demos#index</h1>
+
+<p>Find me in app/views/demos/index.html.erb</p>
+
+
View
41 config/routes.rb
@@ -1,43 +1,8 @@
ActionController::Routing::Routes.draw do |map|
- # The priority is based upon order of creation: first created -> highest priority.
-
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
-
- # Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
-
- # Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
- # Sample resource route with more complex sub-resources
- # map.resources :products do |products|
- # products.resources :comments
- # products.resources :sales, :collection => { :recent => :get }
- # end
-
- # Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
- # end
-
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
-
- # See how all your routes lay out with "rake routes"
-
- # Install the default routes as the lowest priority.
- # Note: These default routes make all actions in every controller accessible via GET requests. You should
- # consider removing or commenting them out if you're using named routes and resources.
+ map.resources :demos
+
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
+
end
View
0 log/test.log
No changes.
View
11 test/functional/demos_controller_test.rb
@@ -0,0 +1,11 @@
+require 'test_helper'
+
+class DemosControllerTest < ActionController::TestCase
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_select 'h1#demoIndex', 'Demos#index'
+ end
+
+end
View
13 test/integration/holygrail_test.rb
@@ -0,0 +1,13 @@
+require 'test_helper_integration'
+
+class HolygrailTest < ActionController::IntegrationTest
+
+ test "All things JS related" do
+ visit demos_path
+ assert page.has_selector?('h1#demoIndex'), 'should load the h1 normally'
+ find('h1#demoIndex').click
+ assert !page.has_selector?('h1#demoIndex'), 'should remove h1 after clicking it'
+ end
+
+
+end
View
30 test/test_helper.rb
@@ -3,36 +3,12 @@
require 'test_help'
class ActiveSupport::TestCase
- # Transactional fixtures accelerate your tests by wrapping each test method
- # in a transaction that's rolled back on completion. This ensures that the
- # test database remains unchanged so your fixtures don't have to be reloaded
- # between every test method. Fewer database queries means faster tests.
- #
- # Read Mike Clark's excellent walkthrough at
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
- #
- # Every Active Record database supports transactions except MyISAM tables
- # in MySQL. Turn off transactional fixtures in this case; however, if you
- # don't care one way or the other, switching from MyISAM to InnoDB tables
- # is recommended.
- #
- # The only drawback to using transactional fixtures is when you actually
- # need to test transactions. Since your test is bracketed by a transaction,
- # any transactions started in your code will be automatically rolled back.
+
self.use_transactional_fixtures = true
-
- # Instantiated fixtures are slow, but give you @david where otherwise you
- # would need people(:david). If you don't want to migrate your existing
- # test cases which use the @david style and don't mind the speed hit (each
- # instantiated fixtures translates to a database query per test method),
- # then set this back to true.
self.use_instantiated_fixtures = false
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
fixtures :all
- # Add more helper methods to be used by all tests here...
+
+
end
View
13 test/test_helper_integration.rb
@@ -0,0 +1,13 @@
+require "test_helper"
+require "capybara/rails"
+
+class ActionController::IntegrationTest
+
+ include Capybara::DSL
+
+ Capybara.default_driver = :webkit
+
+
+
+end
+
View
4 test/unit/helpers/demos_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class DemosHelperTest < ActionView::TestCase
+end

0 comments on commit 77e0c67

Please sign in to comment.
Something went wrong with that request. Please try again.