spec/spec_helper.rb in redditor-0.1.12 vs spec/spec_helper.rb in redditor-0.1.14

- old
+ new

@@ -12,12 +12,21 @@ require 'capybara/rails' require 'capybara/rspec' require 'capybara/poltergeist' +Capybara.default_wait_time = ENV['CAPYBARA_WAIT_TIME'].present? ? ENV['CAPYBARA_WAIT_TIME'].to_i : 5 + +Capybara.register_driver :poltergeist do |app| + Capybara::Poltergeist::Driver.new(app, { + debug: false, + phantomjs_options: ['--load-images=no', '--disk-cache=false'], + js_errors: false + }) +end + Capybara.javascript_driver = :poltergeist -Capybara.default_wait_time = 10 # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } @@ -44,13 +53,10 @@ end end config.include FactoryGirl::Syntax::Methods - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - 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. config.use_transactional_fixtures = false @@ -62,6 +68,14 @@ # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = "random" +end + +def wait_until + require "timeout" + Timeout.timeout(Capybara.default_wait_time) do + sleep(0.1) until value = yield + value + end end