Skip to content

Instantly share code, notes, and snippets.

View testobsessed's full-sized avatar

Elisabeth Hendrickson testobsessed

View GitHub Profile
@testobsessed
testobsessed / rspec with devise
Created May 24, 2011 19:05
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 March 1, 2011 01:37
Check if element is invisible with Capybara
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}")