Skip to content

Instantly share code, notes, and snippets.

@markoa
Created December 9, 2010 15:32
Show Gist options
  • Select an option

  • Save markoa/734838 to your computer and use it in GitHub Desktop.

Select an option

Save markoa/734838 to your computer and use it in GitHub Desktop.
Mislav's method to log in without messing with the form in Cucumber
# Eg Given I am logged in as @mislav
#
Given /^I am logged in as @(\w+)$/ do |username|
visit "/login/#{username}"
@current_user = User.find_by_login(username)
end
if Rails.env.cucumber?
map.login_backdoor '/login/:username',
:controller => 'sessions', :action => 'backdoor'
end
class SessionsController < ApplicationController
# for cucumber testing only
def backdoor
logout_killing_session!
self.current_user = User.find_by_login!(params[:username])
head :ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment