Skip to content

Commit

Permalink
Fix host/port for capybara-webkit.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed May 12, 2011
1 parent d6148ee commit 41dd4ea
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/controllers/demos_controller.rb
Expand Up @@ -2,5 +2,9 @@ class DemosController < ApplicationController


def index def index
end end

def goto_index
redirect_to demos_url
end


end end
3 changes: 2 additions & 1 deletion config/routes.rb
@@ -1,6 +1,7 @@
ActionController::Routing::Routes.draw do |map| 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'
map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id.:format'
Expand Down
8 changes: 7 additions & 1 deletion test/functional/demos_controller_test.rb
Expand Up @@ -2,10 +2,16 @@


class DemosControllerTest < ActionController::TestCase class DemosControllerTest < ActionController::TestCase


test "should get index" do test "Get index" do
get :index get :index
assert_response :success assert_response :success
assert_select 'h1#demoIndex', 'Demos#index' assert_select 'h1#demoIndex', 'Demos#index'
end end

test "Redirect to index" do
get :goto_index
assert_redirected_to demos_url
end



end end
7 changes: 7 additions & 0 deletions test/integration/holygrail_test.rb
Expand Up @@ -3,10 +3,17 @@
class HolygrailTest < ActionController::IntegrationTest class HolygrailTest < ActionController::IntegrationTest


test "All things JS related" do test "All things JS related" do
# Get index
visit demos_path visit demos_path
assert page.has_selector?('h1#demoIndex'), 'should load the h1 normally' assert page.has_selector?('h1#demoIndex'), 'should load the h1 normally'
find('h1#demoIndex').click find('h1#demoIndex').click
assert !page.has_selector?('h1#demoIndex'), 'should remove h1 after clicking it' 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 end




Expand Down
37 changes: 32 additions & 5 deletions test/test_helper_integration.rb
@@ -1,13 +1,40 @@
require "test_helper" require "test_helper"
require "capybara/rails" require "capybara/rails"


class ActionController::IntegrationTest Capybara.default_driver = :webkit

Capybara.server_port = 50420
include Capybara::DSL

module ActionController
Capybara.default_driver = :webkit


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 end


0 comments on commit 41dd4ea

Please sign in to comment.