Module: OperaWatir::DesktopHelper
Defined Under Namespace
Modules: SpecHelpers
Constant Summary collapse
- @@files =
[]
Instance Method Summary collapse
- #browser ⇒ Object
- #configure_rspec! ⇒ Object
- #linux? ⇒ Boolean
- #mac? ⇒ Boolean
- #run!(settings = {}) ⇒ Object
- #settings ⇒ Object
Instance Method Details
#browser ⇒ Object
21 22 23 |
# File 'lib/operawatir/desktop_helper.rb', line 21 def browser @browser ||= OperaWatir::DesktopBrowser.new end |
#configure_rspec! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/operawatir/desktop_helper.rb', line 33 def configure_rspec! RSpec.configure do |config| if mac? config.filter_run_excluding :nonmac? => true end if linux? == false config.filter_run_excluding :nix? => true end # Set every RSpec option settings.each do |key, value| config.send("#{key}=", value) if config.respond_to?("#{key}=") if key.to_s.eql?("files_to_run") @@files = value end if key.to_s.eql?("files_or_directories_to_run") @@files = value end end config.include SpecHelpers config.before(:all) { if OperaWatir::DesktopHelper::settings[:no_restart] == false unless @@files.empty? path = File.join(Dir.getwd, @@files.shift) filepath = path.chomp(".rb") browser.reset_prefs(filepath) end else # Must create browser object here so that none of the # test is run before Opera has been launched browser end browser.set_preference("User Prefs", "Enable UI Animations", 0) } config.after(:suite) { # Use the @browser directly because we don't want # to launch Opera here if it's not running if @browser if settings[:no_quit] == false # Shutdown Opera @browser.quit_opera @browser.delete_profile end # Shutdown the driver @browser.quit_driver end } end end |
#linux? ⇒ Boolean
29 30 31 |
# File 'lib/operawatir/desktop_helper.rb', line 29 def linux? Config::CONFIG['target_os'] == "linux" end |
#mac? ⇒ Boolean
25 26 27 |
# File 'lib/operawatir/desktop_helper.rb', line 25 def mac? Config::CONFIG['target_os'] == "darwin" end |
#run!(settings = {}) ⇒ Object
92 93 94 95 96 |
# File 'lib/operawatir/desktop_helper.rb', line 92 def run!(settings={}) OperaWatir::DesktopBrowser.settings = settings configure_rspec! RSpec::Core::Runner.autorun end |
#settings ⇒ Object
17 18 19 |
# File 'lib/operawatir/desktop_helper.rb', line 17 def settings OperaWatir::DesktopBrowser.settings end |