Created
February 9, 2012 00:26
-
-
Save rschmukler/1775805 to your computer and use it in GitHub Desktop.
Capybara-Webkit Visibility Error
This file contains 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
def login_user(user = nil) | |
hash = {} | |
unless user.nil? | |
hash = {:provider => user.provider.to_sym, :uuid => user.uid, user.provider.to_sym => {:email => user.email}} | |
end | |
set_omniauth(hash) | |
visit root_path | |
click_link 'Sign In' | |
end | |
def set_omniauth(opts = {}) | |
default = {:provider => :facebook, | |
:uuid => "1234", | |
:facebook => { | |
:email => "JonDoe@example.com", | |
:gender => "Male", | |
:name => 'Jon Doe', | |
:first_name => "Jon", | |
:last_name => "Doe" | |
} | |
} | |
credentials = default.merge(opts) | |
provider = credentials[:provider] | |
user_hash = credentials[provider] | |
OmniAuth.config.test_mode = true | |
OmniAuth.config.mock_auth[provider] = { | |
'uid' => credentials[:uuid], | |
'provider' => credentials[:provider], | |
"info" => { | |
"email" => user_hash[:email], | |
"name" => user_hash[:name], | |
"first_name" => user_hash[:first_name], | |
"last_name" => user_hash[:last_name], | |
"gender" => user_hash[:gender] | |
} | |
} | |
end |
This file contains 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
Failure/Error: login_user @user | |
Capybara::Driver::Webkit::Node::ElementNotDisplayedError: | |
This element is not visible so it may not be interacted with | |
# (eval):2:in `click_link' | |
# ./spec/support/acceptance_helper.rb:10:in `login_user' | |
# ./spec/acceptance/user_management_feature_spec.rb:12:in `block (2 levels) in <top (required)>' |
This file contains 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
<!DOCTYPE html><html><head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>ProjectName</title> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css"> | |
<script src="/assets/application.js" type="text/javascript"></script> | |
</head> | |
<body class="site"> | |
<div class="navbar navbar-fixed"> | |
<div class="navbar-inner"> | |
<div class="container"> | |
<a href="/" class="brand">ProjectName</a> | |
<ul class="nav"> | |
<li class="active"><a href="#">Home</a></li> | |
<li><a href="#" class="">About</a></li> | |
<li><a href="#" class="">FAQ</a></li> | |
</ul> | |
<ul class="nav pull-right"> | |
<li class="vertical-divider"></li> | |
<li><a href="/sign_in">Sign In</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<div class="container"> | |
<h1>Site#index</h1> | |
<p>Find me in app/views/site/index.html.erb</p> | |
</div> | |
</body></html> |
This file contains 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
require 'support/acceptance_helper.rb' | |
feature "User Management" do | |
scenario "Sign In with Valid Credentials", js: true do | |
@user = Factory.create(:user_with_room) | |
login_user(@user) | |
notice_message.should have_content("Welcome back to ProjectName, #{@user.first_name}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment