make integration spec work with javascript driver too

This commit is contained in:
wvengen 2013-07-24 02:57:45 +02:00
parent a858ceedea
commit 0d33922ed9
4 changed files with 33 additions and 2 deletions

View File

@ -71,4 +71,6 @@ group :development, :test do
gem 'factory_girl_rails', '~> 4.0'
gem 'faker'
gem 'capybara'
gem 'poltergeist'
gem 'database_cleaner'
end

View File

@ -90,6 +90,7 @@ GEM
coffee-script-source (1.3.3)
commonjs (0.2.6)
daemons (1.1.9)
database_cleaner (0.7.1)
diff-lcs (1.2.4)
erubis (2.7.0)
eventmachine (1.0.3)
@ -105,6 +106,8 @@ GEM
railties (>= 3.0.0)
faker (1.1.2)
i18n (~> 0.5)
faye-websocket (0.4.7)
eventmachine (>= 0.12.0)
ffi (1.4.0)
haml (3.1.7)
haml-rails (0.3.5)
@ -116,6 +119,7 @@ GEM
hashery (2.0.1)
highline (1.6.19)
hike (1.2.1)
http_parser.rb (0.5.3)
i18n (0.6.1)
inherited_resources (1.3.1)
has_scope (~> 0.5.0)
@ -168,6 +172,10 @@ GEM
Ascii85 (~> 1.0.0)
hashery (~> 2.0)
ruby-rc4
poltergeist (1.1.2)
capybara (~> 2.0.1)
faye-websocket (~> 0.4.4)
http_parser.rb (~> 0.5.3)
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.3)
@ -308,6 +316,7 @@ DEPENDENCIES
client_side_validations
coffee-rails (~> 3.2.1)
daemons
database_cleaner
exception_notification
factory_girl_rails (~> 4.0)
faker
@ -319,6 +328,7 @@ DEPENDENCIES
mailcatcher
meta_search
mysql2
poltergeist
prawn
quiet_assets
rails (~> 3.2.9)

View File

@ -6,6 +6,8 @@ require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
@ -23,7 +25,15 @@ RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
#config.use_transactional_fixtures = true
# We use capybara with selenium, and need database_cleaner
config.before(:each) do
DatabaseCleaner.strategy = (example.metadata[:js] ? :truncation : :transaction)
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
@ -57,3 +67,8 @@ ActionDispatch::Integration::Runner.class_eval do
end
end
# debug driver for tests requiring javascript
#Capybara.javascript_driver = :poltergeist_debug
#Capybara.register_driver :poltergeist_debug do |app|
# Capybara::Poltergeist::Driver.new(app, :debug => true, :inspector => true)
#end

View File

@ -4,7 +4,11 @@ module SessionHelper
def login(user=nil, password=nil)
visit login_path
user = FactoryGirl.create :user if user.nil?
nick, password = user.nick, user.password if user.instance_of? ::User
if user.instance_of? ::User
nick, password = user.nick, user.password
else
nick = user
end
fill_in 'nick', :with => nick
fill_in 'password', :with => password
find('input[type=submit]').click