Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. require "cucumber"
  2. require 'capybara/cucumber'
  3. require 'capybara/poltergeist'
  4. require 'selenium-webdriver'
  5. require "capybara"
  6. require "site_prism"
  7. require "active_support"
  8. require "rspec"
  9. require "mysql2"
  10.  
  11. METRICS_CONFIG_FILE = File.expand_path("config/metrics.yml")
  12. TESTENV = "staging"
  13. BROWSER = "firefox"
  14.  
  15. ActiveSupport::Dependencies.autoload_paths << File.expand_path(File.join(Dir.pwd, 'lib'))
  16.  
  17. if ENV['IN_BROWSER']
  18. # On demand: non-headless tests via Selenium/WebDriver
  19. # To run the scenarios in browser (default: Firefox), use the following command line:
  20. # IN_BROWSER=true bundle exec cucumber
  21. # or (to have a pause of 1 second between each step):
  22. # IN_BROWSER=true PAUSE=1 bundle exec cucumber
  23. Capybara.default_driver = :selenium
  24.  
  25. Capybara.register_driver :selenium do |app|
  26. require 'selenium/webdriver'
  27. profile = Selenium::WebDriver::Firefox::Profile.new
  28. profile['browser.helperApps.alwaysAsk.force'] = false
  29. profile['browser.cache.disk.enable'] = false
  30. profile['browser.cache.memory.enable'] = false
  31. Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
  32. end
  33.  
  34. else
  35. Capybara.run_server = false
  36. Capybara.default_driver = :poltergeist
  37. Capybara.register_driver :poltergeist do |app|
  38. options = {
  39. :js_errors => false,
  40. :phantomjs_logger => File.open("log/test_phantomjs.log", "a"),
  41. :timeout => 120,
  42. :debug => false,
  43. :phantomjs_options => ['--load-images=no', '--disk-cache=false'],
  44. :inspector => false,
  45. }
  46. Capybara::Poltergeist::Driver.new(app, options)
  47. end
  48. end
  49.  
  50. Capybara.default_selector = :css
  51.  
  52. module Helpers
  53. def without_resynchronize
  54. page.driver.options[:resynchronize] = false
  55. yield
  56. page.driver.options[:resynchronize] = true
  57. end
  58. end
  59.  
  60. World(Capybara::DSL, Helpers)
  61.  
  62. # World(ShowMeTheCookies)
  63.  
  64. def config
  65. config_file = "#{File.dirname(__FILE__)}/config_local.yml"
  66. if ENV['CONFIG_FILE']
  67. config_file = "#{File.dirname(__FILE__)}/" + ENV['CONFIG_FILE']
  68. end
  69. puts "config_file: " + config_file
  70. YAML.load_file(config_file)
  71. end
  72.  
  73. def rest
  74. sleep config['sleep_time']
  75. end
  76.  
  77. RSpec.configure do |config|
  78. # config.include ShowMeTheCookies, :type => :feature
  79. config.run_all_when_everything_filtered = true
  80. config.filter_run :focus
  81.  
  82. # Run specs in random order to surface order dependencies. If you find an
  83. # order dependency and want to debug it, you can fix the order by providing
  84. # the seed, which is printed after each run.
  85. # --seed 1234
  86. config.order = 'random'
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement