Created
December 15, 2010 23:31
-
-
Save santiago/742777 to your computer and use it in GitHub Desktop.
Cucumber+Capybara+Selenium not keeping session
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
# Edit at your own peril - it's recommended to regenerate this file | |
# in the future when you upgrade to a newer version of Cucumber. | |
# IMPORTANT: Setting config.cache_classes to false is known to | |
# break Cucumber's use_transactional_fixtures method. | |
# For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165 | |
config.cache_classes = true | |
# Log error messages when you accidentally call methods on nil. | |
config.whiny_nils = true | |
# Show full error reports and disable caching | |
config.action_controller.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
# Disable request forgery protection in test environment | |
config.action_controller.allow_forgery_protection = false | |
# Tell Action Mailer not to deliver emails to the real world. | |
# The :test delivery method accumulates sent emails in the | |
# ActionMailer::Base.deliveries array. | |
config.action_mailer.delivery_method = :test | |
config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails')) | |
config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner')) | |
config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(File.join(Rails.root, 'vendor/plugins/capybara')) | |
config.gem 'rspec', :lib => false, :version => '>=1.3.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec')) | |
config.gem 'rspec-rails', :lib => false, :version => '>=1.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails')) | |
config.gem 'factory_girl', :lib => false, :version => '>=1.3.2' |
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
ENV["RAILS_ENV"] ||= "cucumber" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support | |
require 'cucumber/rails/rspec' | |
require 'cucumber/rails/world' | |
require 'cucumber/rails/active_record' | |
require 'cucumber/web/tableish' | |
require 'capybara/rails' | |
require 'capybara/cucumber' | |
require 'capybara/session' | |
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript | |
require 'shoulda' | |
require 'factory_girl' | |
Dir.glob(File.join(File.dirname(__FILE__), '../../spec/factories/*.rb')).each {|f| require f } | |
Capybara.default_selector = :css | |
Capybara.current_driver = :selenium | |
ActionController::Base.allow_rescue = false | |
Cucumber::Rails::World.use_transactional_fixtures = true | |
if defined?(ActiveRecord::Base) | |
begin | |
require 'database_cleaner' | |
DatabaseCleaner.strategy = :truncation | |
rescue LoadError => ignore_if_database_cleaner_not_present | |
end | |
end | |
World(Util, Domain::CYN, Domain::WakeUpCall, Domain::ActionAgreements) |
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
@nsbg @javascript | |
Feature: NSBG | |
As a partner I can choose Needs, set a Satisfaction Level for each | |
Need, set a Priority for each Need, and Share my current Satisfaction Levels | |
with My Partner | |
Scenario: Choose Needs | |
Given I'm logged in |
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
# Saw this in, yet does not work ... | |
# http://blog.mindtonic.net/using_authlogic_with_cucumber | |
# https://github.com/mindtonic/AuthLogic-Cucumber-Steps/blob/master/step_definitions/authentication_steps.rb | |
Before do | |
include Authlogic::TestCase | |
activate_authlogic | |
end | |
Given /^I'm logged in$/ do | |
Factory.create(:user) | |
visit('/') | |
click_link 'login-tab' | |
within("#new_user_session") do | |
fill_in 'user_session_login', :with => 'santiago' | |
fill_in 'user_session_password', :with => 'santiago' | |
end | |
click_button 'user_session_submit' | |
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
Factory.define :user do |u| | |
u.login 'santiago' | |
u.password 'santiago' | |
u.email '[email protected]' | |
u.password_confirmation 'santiago' | |
u.active true | |
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
class UserSessionsController < ApplicationController | |
... | |
def create | |
@user_session = UserSession.new(params[:user_session]) | |
if @user_session.save! | |
# it does get here ... | |
p "it gets here!" | |
# ... but no redirection is performed | |
redirect_to :controller => "home" | |
end | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment