Created
December 22, 2010 12:32
-
-
Save trevorturk/751452 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test/integration/example_test.rb | |
require "test_helper" | |
class ExampleTest < ActionController::IntegrationTest | |
setup do | |
Admin.create(:email => '[email protected]', :password => 'password') | |
end | |
test "admin sign in" do | |
visit admin_root_path | |
assert_equal current_path, new_admin_session_path | |
fill_in 'admin_email', :with => '[email protected]' | |
fill_in 'admin_password', :with => 'invalid' | |
click_button 'admin_submit' | |
assert page.has_content?('Invalid email or password') | |
assert_equal current_path, new_admin_session_path | |
fill_in 'admin_email', :with => '[email protected]' | |
fill_in 'admin_password', :with => 'password' | |
click_button 'admin_submit' | |
assert page.has_content?('Signed in successfully') | |
assert_equal current_path, admin_root_path | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
source 'http://rubygems.org' | |
gem 'rails' | |
group :test do | |
gem 'capybara' | |
gem 'launchy' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test/test_helper.rb | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
require 'capybara/rails' | |
class ActiveSupport::TestCase | |
setup do | |
Capybara.reset_sessions! | |
end | |
end | |
class ActionController::IntegrationTest | |
include Capybara | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is interesting.
You write:
current_path
matchesnew_admin_session_path
, no problem here.Instead if you write:
Then
current_path
does not matchnew_admin_session_path
I think it is because the page is not loaded fast enough for Capybara.
Too bad as the latter style is more logical.