Hi fellow software developers,
I have a Rails app with a usual testsuite set up (RSpec, Capybara, Poltergeist, jQuery, Rails). I use a little Javascript(jQuery) for remote requests. Basically it works and I don't understand my problem yet. So I may update the question with further knowledge.
Maybe you could give me some hints what to investigate before I post lots of irrelevant code and config.
The inconsistent and unexpected behaviour is in a feature spec that tests via Poltergeist in Capybara that the User interaction (clicking forms and links) hides and shows HTML-elements via AJAX with jQuery.
It seemed that it even works correctly if I test manually. Setting Capybara default time to wait changed only the time I had to wait until the spec run =). I found no other relevant configuration or usage yet.
So any help/idea is much appreciated. Thanks in advance.
My spec_helper:
require 'simplecov'
require 'rubygems'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'email_spec'
require 'rspec/autorun'
require 'rspec/rails'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'capybara/rails'
Capybara.javascript_driver = :poltergeist
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
config.include Capybara::DSL
#config.include Capybara::RSpecMatchers
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# 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.
# set to false with Capybara + Database Cleaner
# set to true with ActiveRecord::Base patch from Jose Valim and without Database Cleaner
config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = true
config.order = "random"
config.include FactoryGirl::Syntax::Methods
config.after(:each) do
# some model deletion
model.delete_all
end
config.include FeatureHelpers
end
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@shared_connection || retrieve_connection
end
end
# # Forces all threads to share the same connection. This works on Capybara
# # because it starts the web server in a thread
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
FactoryGirl.reload