Permalink
Browse files

Fix host/port for capybara-webkit.

  • Loading branch information...
1 parent d6148ee commit 41dd4eaf175c311d59dfe124b2107757c56902a4 @metaskills committed May 12, 2011
@@ -2,5 +2,9 @@ class DemosController < ApplicationController
def index
end
+
+ def goto_index
+ redirect_to demos_url
+ end
end
View
@@ -1,6 +1,7 @@
ActionController::Routing::Routes.draw do |map|
- map.resources :demos
+ map.resources :demos,
+ :collection => { :goto_index => :get }
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
@@ -2,10 +2,16 @@
class DemosControllerTest < ActionController::TestCase
- test "should get index" do
+ test "Get index" do
get :index
assert_response :success
assert_select 'h1#demoIndex', 'Demos#index'
end
+
+ test "Redirect to index" do
+ get :goto_index
+ assert_redirected_to demos_url
+ end
+
end
@@ -3,10 +3,17 @@
class HolygrailTest < ActionController::IntegrationTest
test "All things JS related" do
+ # Get index
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'
+
+ # raise goto_index_demos_url.inspect
+
+ # Redirect to index
+ visit goto_index_demos_path
+ assert_equal demos_url, page.current_url
end
@@ -1,13 +1,40 @@
require "test_helper"
require "capybara/rails"
-class ActionController::IntegrationTest
-
- include Capybara::DSL
-
- Capybara.default_driver = :webkit
+Capybara.default_driver = :webkit
+Capybara.server_port = 50420
+
+module ActionController
+ module Integration
+ class Session
+
+ DEFAULT_HOST = '127.0.0.1'
+
+ def host
+ DEFAULT_HOST
+ end
+
+ def reset_with_capybara_webkit!
+ reset_without_capybara_webkit!
+ self.host = DEFAULT_HOST
+ end
+ alias_method_chain :reset!, :capybara_webkit
+
+ def url_for_with_capybara_webkit(options)
+ options[:host] = host
+ options[:port] = Capybara.server_port
+ url_for_without_capybara_webkit(options)
+ end
+ alias_method_chain :url_for, :capybara_webkit
+
+ end
+ end
+ class IntegrationTest
+ include Capybara::DSL
+ end
+
end

0 comments on commit 41dd4ea

Please sign in to comment.