Skip to content
Browse files

Setup capybara

  • Loading branch information...
1 parent d725629 commit 610633545da07c9a2e3ba99ac50c61165765e093 @edavis10 committed Dec 28, 2010
Showing with 27 additions and 17 deletions.
  1. +13 −0 test/integration/capybara_test.rb
  2. +14 −17 test/test_helper.rb
View
13 test/integration/capybara_test.rb
@@ -0,0 +1,13 @@
+require 'test_helper'
+
+class CapybaraTest < ActionController::IntegrationTest
+ should "work" do
+ @user = User.generate_with_protected!(:login => 'existing', :password => 'existing', :password_confirmation => 'existing')
+ login_as
+
+ @project = Project.generate!(:is_public => true)
+ visit_project(@project)
+ assert find(:css, 'body')
+ end
+end
+
View
31 test/test_helper.rb
@@ -4,35 +4,31 @@
# Ensure that we are using the temporary fixture path
Engines::Testing.set_fixture_path
-require "webrat"
-
-Webrat.configure do |config|
- config.mode = :rails
-end
+require 'capybara/rails'
def User.add_to_project(user, project, role)
Member.generate!(:principal => user, :project => project, :roles => [role])
end
-module RedmineWebratHelper
+module RedmineCapybaraHelper
def login_as(user="existing", password="existing")
visit "/login"
fill_in 'Login', :with => user
fill_in 'Password', :with => password
- click_button 'login'
- assert_response :success
+ click_button 'Login'
+ assert_equal 200, page.status_code
assert User.current.logged?
end
def visit_project(project)
visit '/'
- assert_response :success
+ assert_equal 200, page.status_code
click_link 'Projects'
- assert_response :success
+ assert_equal 200, page.status_code
click_link project.name
- assert_response :success
+ assert_equal 200, page.status_code
end
def visit_issue_page(issue)
@@ -43,16 +39,17 @@ def visit_issue_bulk_edit_page(issues)
visit url_for(:controller => 'issues', :action => 'bulk_edit', :ids => issues.collect(&:id))
end
- # Cleanup current_url to remove the host; sometimes it's present, sometimes it's not
- def current_path
- return nil if current_url.nil?
- return current_url.gsub("http://www.example.com","")
- end
+ # # Cleanup current_url to remove the host; sometimes it's present, sometimes it's not
+ # def current_path
+ # return nil if current_url.nil?
+ # return current_url.gsub("http://www.example.com","")
+ # end
end
class ActionController::IntegrationTest
- include RedmineWebratHelper
+ include RedmineCapybaraHelper
+ include Capybara
end
class ActiveSupport::TestCase

0 comments on commit 6106335

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