Skip to content

Instantly share code, notes, and snippets.

Elisabeth Hendrickson testobsessed

View GitHub Profile
View rspec with devise
def login_as(user)
raise "Was expecting a User. Got a #{user.class} instead. Exiting." if user.class != User
@controller.request.env['warden'] = mock(
Warden,
:authenticate => user,
:authenticate! => user,
:authenticated? => true,
:authenticate? => true
)
user.last_sign_in_at = Time.now
@testobsessed
testobsessed / capybara_helper.rb
Created Mar 1, 2011
Check if element is invisible with Capybara
View capybara_helper.rb
def element_visible?(element_id)
# does the element exist?
exists = page.has_css?(element_id)
# is the element itself hidden with the .ui-helper-hidden class?
self_hidden = page.has_css?("#{element_id}.ui-helper-hidden")
# is the parent of the element hidden, thus hiding the element?
parent_hidden = page.has_css?(".ui-helper-hidden > #{element_id}")
You can’t perform that action at this time.