mediawiki_selenium 1.0.0.pre.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +23 -1
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +1 -4
  6. data/UPGRADE.md +1 -1
  7. data/bin/mediawiki-selenium-init +1 -1
  8. data/lib/mediawiki_selenium/browser_factory/base.rb +8 -8
  9. data/lib/mediawiki_selenium/browser_factory/chrome.rb +1 -1
  10. data/lib/mediawiki_selenium/browser_factory/firefox.rb +4 -4
  11. data/lib/mediawiki_selenium/browser_factory/phantomjs.rb +2 -2
  12. data/lib/mediawiki_selenium/browser_factory.rb +5 -5
  13. data/lib/mediawiki_selenium/environment.rb +15 -14
  14. data/lib/mediawiki_selenium/initializer.rb +4 -4
  15. data/lib/mediawiki_selenium/page_factory.rb +1 -1
  16. data/lib/mediawiki_selenium/remote_browser_factory.rb +12 -8
  17. data/lib/mediawiki_selenium/step_definitions/login_steps.rb +0 -11
  18. data/lib/mediawiki_selenium/step_definitions/navigation_steps.rb +0 -11
  19. data/lib/mediawiki_selenium/step_definitions/preferences_steps.rb +0 -11
  20. data/lib/mediawiki_selenium/step_definitions/resource_loader_steps.rb +0 -11
  21. data/lib/mediawiki_selenium/step_definitions/upload_file_steps.rb +3 -3
  22. data/lib/mediawiki_selenium/step_definitions.rb +5 -5
  23. data/lib/mediawiki_selenium/support/env.rb +5 -16
  24. data/lib/mediawiki_selenium/support/hooks.rb +15 -26
  25. data/lib/mediawiki_selenium/support/modules/api_helper.rb +5 -7
  26. data/lib/mediawiki_selenium/support/pages/api_page.rb +6 -6
  27. data/lib/mediawiki_selenium/support/pages/login_page.rb +13 -12
  28. data/lib/mediawiki_selenium/support/pages/random_page.rb +2 -2
  29. data/lib/mediawiki_selenium/support/pages/reset_preferences_page.rb +3 -3
  30. data/lib/mediawiki_selenium/support/pages.rb +4 -4
  31. data/lib/mediawiki_selenium/support/sauce.rb +14 -18
  32. data/lib/mediawiki_selenium/support.rb +4 -4
  33. data/lib/mediawiki_selenium/version.rb +1 -12
  34. data/lib/mediawiki_selenium/warnings_formatter.rb +15 -15
  35. data/lib/mediawiki_selenium.rb +8 -19
  36. data/mediawiki_selenium.gemspec +35 -28
  37. data/spec/api_helper_spec.rb +25 -25
  38. data/spec/browser_factory/base_spec.rb +50 -46
  39. data/spec/browser_factory/chrome_spec.rb +11 -11
  40. data/spec/browser_factory/firefox_spec.rb +17 -17
  41. data/spec/browser_factory/phantomjs_spec.rb +11 -11
  42. data/spec/environment_spec.rb +194 -159
  43. data/spec/page_factory_spec.rb +12 -12
  44. data/spec/remote_browser_factory_spec.rb +15 -15
  45. data/spec/spec_helper.rb +2 -2
  46. data/templates/tests/browser/features/support/env.rb +3 -3
  47. metadata +9 -9
  48. data/.rubocop_todo.yml +0 -160
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93a8424d3894106aa9575f18912096df4d6bda83
4
- data.tar.gz: 226dbf63109a48e9ede7a3d2346a7356e697782b
3
+ metadata.gz: 834dc185ba694c50b41bd95e0364c4c75071a8bf
4
+ data.tar.gz: 5a0425ce60b219c451b046653945a3561947f7e0
5
5
  SHA512:
6
- metadata.gz: 81739dccd7bedc37d73e438b4d58bf301580e5d0d6ae3d4fbb7d7da2221c92e3be1ddfd5d68a2461cbada9d999f078d0f0c65120ebf841708a97b54c3ac1a83a
7
- data.tar.gz: dbcb5db3ae8620ed8ff25279440ea3f381e0cfd4f7b378c7b5c75069ba15c71a94f0bea73670db0b45f393e4980e358ca6903895fba3fd6de9696ca862886270
6
+ metadata.gz: 44f9e8fbe4cae9d9e30044ac2986601cb72859af136f07723755d58084ce6225766ddc21bd3d16e59e6bef183ef969213ff6f1e5a1a789ede3e0b0854165ccd5
7
+ data.tar.gz: 956616b547ae43072e3fd3a417fc67910e85539b7da1a354fb07c65d81a0d2fcb00aa48ad0c2b06c61a0bb1151ff8c2cd7033c94f10e203d22b535b88424ef1f
data/.rubocop.yml CHANGED
@@ -1 +1,23 @@
1
- inherit_from: .rubocop_todo.yml
1
+ AllCops:
2
+ StyleGuideCopsOnly: true
3
+
4
+ Metrics/LineLength:
5
+ Max: 100
6
+
7
+ Metrics/MethodLength:
8
+ Enabled: false
9
+
10
+ Style/Alias:
11
+ Enabled: false
12
+
13
+ Style/DotPosition:
14
+ EnforcedStyle: trailing
15
+
16
+ Style/FileName:
17
+ Exclude: ['bin/*']
18
+
19
+ Style/SignalException:
20
+ Enabled: false
21
+
22
+ Style/TrivialAccessors:
23
+ ExactNameMatch: true
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ mediawiki_selenium
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.5
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
- #ruby=ruby-2.1.3
2
- #ruby-gemset=mediawiki_selenium
3
-
4
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
5
2
 
6
3
  gemspec
data/UPGRADE.md CHANGED
@@ -5,7 +5,7 @@
5
5
  First, update the `Gemfile` in your project's root directory to specify the
6
6
  new version.
7
7
 
8
- gem 'mediawiki_selenium', '~> 1.0.0.pre.2'
8
+ gem 'mediawiki_selenium', '~> 1.0.0'
9
9
 
10
10
  ## Upgrade gems and dependencies
11
11
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "mediawiki_selenium"
3
+ require 'mediawiki_selenium'
4
4
 
5
5
  MediawikiSelenium::Initializer.new.install
@@ -1,4 +1,4 @@
1
- require "watir-webdriver"
1
+ require 'watir-webdriver'
2
2
 
3
3
  module MediawikiSelenium
4
4
  module BrowserFactory
@@ -15,8 +15,8 @@ module MediawikiSelenium
15
15
  # @example Always configure Firefox's language according to `:browser_language`
16
16
  # module MediawikiSelenium::BrowserFactory
17
17
  # class Firefox < Base
18
- # bind(:browser_language) do |language, options|
19
- # options[:desired_capabilities][:firefox_profile]["intl.accept_languages"] = language
18
+ # bind(:browser_language) do |lang, options|
19
+ # options[:desired_capabilities][:firefox_profile]["intl.accept_languages"] = lang
20
20
  # end
21
21
  # end
22
22
  # end
@@ -27,7 +27,7 @@ module MediawikiSelenium
27
27
  # the browser options.
28
28
  #
29
29
  def bind(*names, &blk)
30
- raise ArgumentError, "no block given" unless block_given?
30
+ raise ArgumentError, 'no block given' unless block_given?
31
31
 
32
32
  key = names.length == 1 ? names.first : names
33
33
  default_bindings[key] ||= []
@@ -41,7 +41,7 @@ module MediawikiSelenium
41
41
  #
42
42
  def bindings
43
43
  if superclass <= Base
44
- default_bindings.merge(superclass.bindings) { |key, old, new| old + new }
44
+ default_bindings.merge(superclass.bindings) { |_key, old, new| old + new }
45
45
  else
46
46
  default_bindings
47
47
  end
@@ -116,7 +116,7 @@ module MediawikiSelenium
116
116
  # @return [Hash]
117
117
  #
118
118
  def bindings
119
- self.class.bindings.merge(@bindings) { |key, old, new| old + new }
119
+ self.class.bindings.merge(@bindings) { |_key, old, new| old + new }
120
120
  end
121
121
 
122
122
  # Instantiate a browser using the given environmental configuration.
@@ -182,7 +182,7 @@ module MediawikiSelenium
182
182
  # @param env [Environment] Environment.
183
183
  # @param status [Symbol] Status of the executed scenario.
184
184
  #
185
- def teardown(env, status)
185
+ def teardown(_env, _status)
186
186
  # abstract
187
187
  end
188
188
 
@@ -196,7 +196,7 @@ module MediawikiSelenium
196
196
  Selenium::WebDriver::Remote::Capabilities.send(browser_name)
197
197
  end
198
198
 
199
- def finalize_options!(options)
199
+ def finalize_options!(_options)
200
200
  # abstract
201
201
  end
202
202
 
@@ -10,7 +10,7 @@ module MediawikiSelenium
10
10
  #
11
11
  class Chrome < Base
12
12
  bind(:browser_language) do |language, options|
13
- options[:prefs]["intl.accept_languages"] = language
13
+ options[:prefs]['intl.accept_languages'] = language
14
14
  end
15
15
 
16
16
  bind(:browser_user_agent) do |user_agent, options|
@@ -12,16 +12,16 @@ module MediawikiSelenium
12
12
  class Firefox < Base
13
13
  bind(:browser_timeout) do |timeout, options|
14
14
  timeout = timeout.to_i
15
- options[:profile]["dom.max_script_run_time"] = timeout
16
- options[:profile]["dom.max_chrome_script_run_time"] = timeout
15
+ options[:profile]['dom.max_script_run_time'] = timeout
16
+ options[:profile]['dom.max_chrome_script_run_time'] = timeout
17
17
  end
18
18
 
19
19
  bind(:browser_language) do |language, options|
20
- options[:profile]["intl.accept_languages"] = language
20
+ options[:profile]['intl.accept_languages'] = language
21
21
  end
22
22
 
23
23
  bind(:browser_user_agent) do |user_agent, options|
24
- options[:profile]["general.useragent.override"] = user_agent
24
+ options[:profile]['general.useragent.override'] = user_agent
25
25
  end
26
26
 
27
27
  protected
@@ -10,11 +10,11 @@ module MediawikiSelenium
10
10
  #
11
11
  class Phantomjs < Base
12
12
  bind(:browser_language) do |language, options|
13
- options[:desired_capabilities]["phantomjs.page.customHeaders.Accept-Language"] = language
13
+ options[:desired_capabilities]['phantomjs.page.customHeaders.Accept-Language'] = language
14
14
  end
15
15
 
16
16
  bind(:browser_user_agent) do |user_agent, options|
17
- options[:desired_capabilities]["phantomjs.page.settings.userAgent"] = user_agent
17
+ options[:desired_capabilities]['phantomjs.page.settings.userAgent'] = user_agent
18
18
  end
19
19
  end
20
20
  end
@@ -1,9 +1,9 @@
1
1
  module MediawikiSelenium
2
2
  module BrowserFactory
3
- autoload :Base, "mediawiki_selenium/browser_factory/base"
4
- autoload :Firefox, "mediawiki_selenium/browser_factory/firefox"
5
- autoload :Chrome, "mediawiki_selenium/browser_factory/chrome"
6
- autoload :Phantomjs, "mediawiki_selenium/browser_factory/phantomjs"
3
+ autoload :Base, 'mediawiki_selenium/browser_factory/base'
4
+ autoload :Firefox, 'mediawiki_selenium/browser_factory/firefox'
5
+ autoload :Chrome, 'mediawiki_selenium/browser_factory/chrome'
6
+ autoload :Phantomjs, 'mediawiki_selenium/browser_factory/phantomjs'
7
7
 
8
8
  # Resolves and instantiates a new factory for the given browser name.
9
9
  #
@@ -17,7 +17,7 @@ module MediawikiSelenium
17
17
  # @return [BrowserFactory::Base]
18
18
  #
19
19
  def self.new(browser_name)
20
- factory_class = const_get(browser_name.to_s.split("_").map(&:capitalize).join(""))
20
+ factory_class = const_get(browser_name.to_s.split('_').map(&:capitalize).join(''))
21
21
  factory_class.new(browser_name)
22
22
  end
23
23
  end
@@ -1,4 +1,4 @@
1
- require "yaml"
1
+ require 'yaml'
2
2
 
3
3
  module MediawikiSelenium
4
4
  # Provides an interface that unifies environmental configuration, page
@@ -85,11 +85,11 @@ module MediawikiSelenium
85
85
  # @see load
86
86
  #
87
87
  def load_default
88
- load(ENV["MEDIAWIKI_ENVIRONMENT"], ENV)
88
+ load(ENV['MEDIAWIKI_ENVIRONMENT'], ENV)
89
89
  end
90
90
  end
91
91
 
92
- self.default_configuration = "environments.yml"
92
+ self.default_configuration = 'environments.yml'
93
93
 
94
94
  def initialize(*configs)
95
95
  @_config = configs.map { |config| normalize_config(config) }.reduce(:merge)
@@ -168,7 +168,7 @@ module MediawikiSelenium
168
168
  # @return [Symbol]
169
169
  #
170
170
  def browser_name
171
- lookup(:browser, default: "firefox").downcase.to_sym
171
+ lookup(:browser, default: 'firefox').downcase.to_sym
172
172
  end
173
173
 
174
174
  # A reference to this environment. Can be used in conjunction with {#[]}
@@ -227,7 +227,7 @@ module MediawikiSelenium
227
227
  # Whether browsers should be left open after each scenario completes.
228
228
  #
229
229
  def keep_browser_open?
230
- lookup(:keep_browser_open, default: "false") == "true"
230
+ lookup(:keep_browser_open, default: 'false') == 'true'
231
231
  end
232
232
 
233
233
  # Returns the configured value for the given env variable name.
@@ -334,10 +334,10 @@ module MediawikiSelenium
334
334
  # @yieldparam browser [Watir::Browser] Browser object, before it's closed.
335
335
  #
336
336
  def teardown(status = :passed)
337
- @_factory_cache.each do |_, factory|
337
+ @_factory_cache.each do |(_, browser_name), factory|
338
338
  factory.each do |browser|
339
339
  yield browser if block_given?
340
- browser.close unless keep_browser_open?
340
+ browser.close unless keep_browser_open? && browser_name != :phantomjs
341
341
  end
342
342
 
343
343
  factory.teardown(self, status)
@@ -354,7 +354,8 @@ module MediawikiSelenium
354
354
  if scenario.respond_to? :feature
355
355
  "#{scenario.feature.title}: #{scenario.title}"
356
356
  elsif scenario.respond_to? :scenario_outline
357
- "#{scenario.scenario_outline.feature.title}: #{scenario.scenario_outline.title}: #{scenario.name}"
357
+ outline = scenario.scenario_outline
358
+ "#{outline.feature.title}: #{outline.title}: #{scenario.name}"
358
359
  else
359
360
  scenario.name
360
361
  end
@@ -379,7 +380,7 @@ module MediawikiSelenium
379
380
  # @return [String]
380
381
  #
381
382
  def user_label(id = nil)
382
- user(id).gsub("_", " ")
383
+ user(id).gsub('_', ' ')
383
384
  end
384
385
 
385
386
  # Navigates the current browser to the given wiki.
@@ -414,9 +415,9 @@ module MediawikiSelenium
414
415
  # Prefixing relative paths with an explicit "./" guarantees proper
415
416
  # parsing of paths like "Special:Page" that would otherwise be
416
417
  # confused for URI schemes.
417
- if path.include?(":")
418
+ if path.include?(':')
418
419
  path_uri = URI.parse(path)
419
- path = "./#{path}" if path_uri.class == URI::Generic && !path.start_with?("/")
420
+ path = "./#{path}" if path_uri.class == URI::Generic && !path.start_with?('/')
420
421
  end
421
422
 
422
423
  url = URI.parse(url).merge(path).to_s
@@ -463,11 +464,11 @@ module MediawikiSelenium
463
464
  private
464
465
 
465
466
  def browser_config
466
- lookup_all(browser_factory.all_binding_keys, default: nil).reject { |k, v| v.nil? }
467
+ lookup_all(browser_factory.all_binding_keys, default: nil).reject { |_k, v| v.nil? }
467
468
  end
468
469
 
469
470
  def password_variable
470
- name = lookup(:mediawiki_password_variable, default: "")
471
+ name = lookup(:mediawiki_password_variable, default: '')
471
472
  name.empty? ? :mediawiki_password : normalize_key(name)
472
473
  end
473
474
 
@@ -485,7 +486,7 @@ module MediawikiSelenium
485
486
 
486
487
  begin
487
488
  @_config = @_config.merge(overrides)
488
- yield *overrides.values if block_given?
489
+ yield(*overrides.values) if block_given?
489
490
  ensure
490
491
  @_config = original_config
491
492
  end
@@ -1,4 +1,4 @@
1
- require "thor"
1
+ require 'thor'
2
2
 
3
3
  module MediawikiSelenium
4
4
  # Creates the directory structure and configuration for a brand new
@@ -8,12 +8,12 @@ module MediawikiSelenium
8
8
  include Thor::Actions
9
9
 
10
10
  def self.source_root
11
- File.expand_path("../../../templates", __FILE__)
11
+ File.expand_path('../../../templates', __FILE__)
12
12
  end
13
13
 
14
- desc "install", "Creates tests/browser directory structure and default configuration"
14
+ desc 'install', 'Creates tests/browser directory structure and default configuration'
15
15
  def install
16
- directory("tests")
16
+ directory('tests')
17
17
  end
18
18
  end
19
19
  end
@@ -1,4 +1,4 @@
1
- require "page-object"
1
+ require 'page-object'
2
2
 
3
3
  module MediawikiSelenium
4
4
  # Handles on-demand browser instantiation and assignment of the `@browser`
@@ -1,5 +1,7 @@
1
- require "rest_client"
2
- require "uri"
1
+ require 'mediawiki_selenium/support/sauce'
2
+
3
+ require 'rest_client'
4
+ require 'uri'
3
5
 
4
6
  module MediawikiSelenium
5
7
  # Constructs remote browser sessions to be run via Sauce Labs. Adds the
@@ -12,7 +14,7 @@ module MediawikiSelenium
12
14
  #
13
15
  module RemoteBrowserFactory
14
16
  REQUIRED_CONFIG = [:sauce_ondemand_username, :sauce_ondemand_access_key]
15
- URL = "http://ondemand.saucelabs.com/wd/hub"
17
+ URL = 'http://ondemand.saucelabs.com/wd/hub'
16
18
 
17
19
  class << self
18
20
  def extend_object(factory)
@@ -51,13 +53,15 @@ module MediawikiSelenium
51
53
  url: "https://saucelabs.com/rest/v1/#{username}/jobs/#{sid}",
52
54
  user: username,
53
55
  password: key,
54
- headers: { content_type: "application/json" },
56
+ headers: { content_type: 'application/json' },
55
57
  payload: {
56
58
  public: true,
57
59
  passed: status == :passed,
58
- build: env.lookup(:build_number, default: nil),
60
+ build: env.lookup(:build_number, default: nil)
59
61
  }.to_json
60
62
  )
63
+
64
+ Cucumber::Formatter::Sauce.current_session_id = sid
61
65
  end
62
66
  end
63
67
 
@@ -68,9 +72,9 @@ module MediawikiSelenium
68
72
  when :firefox
69
73
  options[:desired_capabilities][:firefox_profile] = options.delete(:profile)
70
74
  when :chrome
71
- options[:desired_capabilities]["chromeOptions"] ||= {}
72
- options[:desired_capabilities]["chromeOptions"]["prefs"] = options.delete(:prefs)
73
- options[:desired_capabilities]["chromeOptions"]["args"] = options.delete(:args)
75
+ options[:desired_capabilities]['chromeOptions'] ||= {}
76
+ options[:desired_capabilities]['chromeOptions']['prefs'] = options.delete(:prefs)
77
+ options[:desired_capabilities]['chromeOptions']['args'] = options.delete(:args)
74
78
  end
75
79
  end
76
80
 
@@ -1,14 +1,3 @@
1
- =begin
2
- This file is subject to the license terms in the LICENSE file found in the
3
- mediawiki_selenium top-level directory and at
4
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
- mediawiki_selenium, including this file, may be copied, modified, propagated, or
6
- distributed except according to the terms contained in the LICENSE file.
7
- Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
- mediawiki_selenium top-level directory and at
9
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
- =end
11
-
12
1
  Given(/^I am logged in(?: as (\w+))$/) do |user|
13
2
  as_user(user) do |user, password|
14
3
  visit(LoginPage).login_with(user, password)
@@ -1,14 +1,3 @@
1
- =begin
2
- This file is subject to the license terms in the LICENSE file found in the
3
- mediawiki_selenium top-level directory and at
4
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
- mediawiki_selenium, including this file, may be copied, modified, propagated, or
6
- distributed except according to the terms contained in the LICENSE file.
7
- Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
- mediawiki_selenium top-level directory and at
9
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
- =end
11
-
12
1
  Given(/^I am at a random page.*$/) do
13
2
  visit RandomPage
14
3
  end
@@ -1,14 +1,3 @@
1
- =begin
2
- This file is subject to the license terms in the LICENSE file found in the
3
- mediawiki_selenium top-level directory and at
4
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
- mediawiki_selenium, including this file, may be copied, modified, propagated, or
6
- distributed except according to the terms contained in the LICENSE file.
7
- Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
- mediawiki_selenium top-level directory and at
9
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
- =end
11
-
12
1
  Given(/^I have reset my preferences$/) do
13
2
  visit(ResetPreferencesPage).submit_element.click
14
3
  end
@@ -1,14 +1,3 @@
1
- =begin
2
- This file is subject to the license terms in the LICENSE file found in the
3
- mediawiki_selenium top-level directory and at
4
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
- mediawiki_selenium, including this file, may be copied, modified, propagated, or
6
- distributed except according to the terms contained in the LICENSE file.
7
- Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
- mediawiki_selenium top-level directory and at
9
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
- =end
11
-
12
1
  Then(/^page has no ResourceLoader errors$/) do
13
2
  result = browser.execute_script(<<-end)
14
3
  return (function() {
@@ -1,6 +1,6 @@
1
1
 
2
2
  When(/^upload bogus file (.+)$/) do |file_name|
3
- require "tempfile"
3
+ require 'tempfile'
4
4
  path = "#{Dir.tmpdir}/#{file_name}"
5
5
 
6
6
  system("touch #{path}")
@@ -14,10 +14,10 @@ end
14
14
 
15
15
 
16
16
  When(/^upload file (.+)$/) do |file_name|
17
- require "tempfile"
17
+ require 'tempfile'
18
18
  path = "#{Dir.tmpdir}/#{file_name}"
19
19
 
20
- require "chunky_png"
20
+ require 'chunky_png'
21
21
  ChunkyPNG::Image.new(Random.new.rand(255), Random.new.rand(255), Random.new.rand(255)).save path
22
22
 
23
23
  if browser.driver.browser == :chrome
@@ -1,5 +1,5 @@
1
- require "mediawiki_selenium/step_definitions/login_steps"
2
- require "mediawiki_selenium/step_definitions/navigation_steps"
3
- require "mediawiki_selenium/step_definitions/preferences_steps"
4
- require "mediawiki_selenium/step_definitions/resource_loader_steps"
5
- require "mediawiki_selenium/step_definitions/upload_file_steps"
1
+ require 'mediawiki_selenium/step_definitions/login_steps'
2
+ require 'mediawiki_selenium/step_definitions/navigation_steps'
3
+ require 'mediawiki_selenium/step_definitions/preferences_steps'
4
+ require 'mediawiki_selenium/step_definitions/resource_loader_steps'
5
+ require 'mediawiki_selenium/step_definitions/upload_file_steps'
@@ -1,21 +1,10 @@
1
- =begin
2
- This file is subject to the license terms in the LICENSE file found in the
3
- mediawiki_selenium top-level directory and at
4
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
- mediawiki_selenium, including this file, may be copied, modified, propagated, or
6
- distributed except according to the terms contained in the LICENSE file.
7
- Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
- mediawiki_selenium top-level directory and at
9
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
- =end
11
-
12
1
  # before all
13
- require "bundler/setup"
14
- require "page-object/page_factory"
15
- require "watir-webdriver"
2
+ require 'bundler/setup'
3
+ require 'page-object/page_factory'
4
+ require 'watir-webdriver'
16
5
 
17
- require "mediawiki_selenium/support/modules/api_helper"
18
- require "mediawiki_selenium/support/modules/strict_pending"
6
+ require 'mediawiki_selenium/support/modules/api_helper'
7
+ require 'mediawiki_selenium/support/modules/strict_pending'
19
8
 
20
9
  World { MediawikiSelenium::Environment.load_default }
21
10
 
@@ -1,31 +1,20 @@
1
- =begin
2
- This file is subject to the license terms in the LICENSE file found in the
3
- mediawiki_selenium top-level directory and at
4
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
- mediawiki_selenium, including this file, may be copied, modified, propagated, or
6
- distributed except according to the terms contained in the LICENSE file.
7
- Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
- mediawiki_selenium top-level directory and at
9
- https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
- =end
11
-
12
- Before("@custom-browser") do |scenario|
1
+ Before('@custom-browser') do |scenario|
13
2
  @scenario = scenario
14
3
  end
15
4
 
16
5
  AfterConfiguration do |config|
17
6
  # Install a formatter that can be used to show feature-related warnings
18
- pretty_format, io = config.formats.find { |(format, io)| format == "pretty" }
19
- config.formats << ["MediawikiSelenium::WarningsFormatter", io] if pretty_format
7
+ pretty_format, io = config.formats.find { |(format, _io)| format == 'pretty' }
8
+ config.formats << ['MediawikiSelenium::WarningsFormatter', io] if pretty_format
20
9
 
21
10
  # Initiate headless mode
22
- if ENV["HEADLESS"] == "true"
23
- require "headless"
11
+ if ENV['HEADLESS'] == 'true' && ENV['BROWSER'] != 'phantomjs'
12
+ require 'headless'
24
13
 
25
14
  headless_options = {}.tap do |options|
26
- options[:display] = ENV["HEADLESS_DISPLAY"] if ENV.include?("HEADLESS_DISPLAY")
27
- options[:reuse] = false if ENV["HEADLESS_REUSE"] == "false"
28
- options[:destroy_at_exit] = false if ENV["HEADLESS_DESTROY_AT_EXIT"] == "false"
15
+ options[:display] = ENV['HEADLESS_DISPLAY'] if ENV.include?('HEADLESS_DISPLAY')
16
+ options[:reuse] = false if ENV['HEADLESS_REUSE'] == 'false'
17
+ options[:destroy_at_exit] = false if ENV['HEADLESS_DESTROY_AT_EXIT'] == 'false'
29
18
  end
30
19
 
31
20
  headless = Headless.new(headless_options)
@@ -46,8 +35,8 @@ Before do |scenario|
46
35
  dependencies = tags.map { |tag| tag.match(/^@extension-(.+)$/) { |m| m[1].downcase } }.compact
47
36
 
48
37
  unless dependencies.empty?
49
- extensions = api.meta(:siteinfo, siprop: "extensions").data["extensions"]
50
- extensions = extensions.map { |ext| ext["name"] }.compact.map(&:downcase)
38
+ extensions = api.meta(:siteinfo, siprop: 'extensions').data['extensions']
39
+ extensions = extensions.map { |ext| ext['name'] }.compact.map(&:downcase)
51
40
  missing = dependencies - extensions
52
41
 
53
42
  if missing.any?
@@ -55,7 +44,7 @@ Before do |scenario|
55
44
 
56
45
  if scenario.feature.respond_to?(:mw_warn)
57
46
  warning = "Skipped feature due to missing wiki extensions: #{missing.join(", ")}"
58
- scenario.feature.mw_warn(warning, "missing wiki extensions")
47
+ scenario.feature.mw_warn(warning, 'missing wiki extensions')
59
48
  end
60
49
  end
61
50
  end
@@ -81,16 +70,16 @@ end
81
70
 
82
71
  After do |scenario|
83
72
  if scenario.respond_to?(:status)
84
- require "fileutils"
73
+ require 'fileutils'
85
74
 
86
75
  teardown(scenario.status) do |browser|
87
- if scenario.failed? && lookup(:screenshot_failures, default: false) == "true"
88
- screen_dir = lookup(:screenshot_failures_path, default: "screenshots")
76
+ if scenario.failed? && lookup(:screenshot_failures, default: false) == 'true'
77
+ screen_dir = lookup(:screenshot_failures_path, default: 'screenshots')
89
78
  FileUtils.mkdir_p screen_dir
90
79
  name = test_name(scenario).gsub(/ /, '_')
91
80
  path = "#{screen_dir}/#{name}.png"
92
81
  browser.screenshot.save path
93
- embed path, "image/png"
82
+ embed path, 'image/png'
94
83
  end
95
84
 
96
85
  end
@@ -1,4 +1,4 @@
1
- require "mediawiki_api"
1
+ require 'mediawiki_api'
2
2
 
3
3
  module MediawikiSelenium
4
4
  # Provides more direct access to the API client from hooks and step
@@ -26,11 +26,9 @@ module MediawikiSelenium
26
26
  # @param id [Symbol] ID of alternative user.
27
27
  #
28
28
  def ensure_account(id)
29
- begin
30
- api.create_account(user(id), password(id))
31
- rescue MediawikiApi::ApiError => e
32
- raise e unless e.code == "userexists"
33
- end
29
+ api.create_account(user(id), password(id))
30
+ rescue MediawikiApi::ApiError => e
31
+ raise e unless e.code == 'userexists'
34
32
  end
35
33
 
36
34
  # Extends parent implementation to also override the API URL. If no API
@@ -53,7 +51,7 @@ module MediawikiSelenium
53
51
  private
54
52
 
55
53
  def api_url_from(wiki_url)
56
- URI.parse(wiki_url).merge("/w/api.php").to_s
54
+ URI.parse(wiki_url).merge('/w/api.php').to_s
57
55
  end
58
56
  end
59
57
  end
@@ -1,5 +1,5 @@
1
- require "page-object"
2
- require "mediawiki_api"
1
+ require 'page-object'
2
+ require 'mediawiki_api'
3
3
 
4
4
  class APIPage
5
5
  include PageObject
@@ -7,12 +7,12 @@ class APIPage
7
7
  def client
8
8
  return @client if defined?(@client)
9
9
 
10
- unless ENV["MEDIAWIKI_API_URL"]
11
- raise "Environment variable MEDIAWIKI_API_URL must be set in order to use the API"
10
+ unless ENV['MEDIAWIKI_API_URL']
11
+ raise 'Environment variable MEDIAWIKI_API_URL must be set in order to use the API'
12
12
  end
13
13
 
14
- @client = MediawikiApi::Client.new(ENV["MEDIAWIKI_API_URL"])
15
- @client.log_in ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]
14
+ @client = MediawikiApi::Client.new(ENV['MEDIAWIKI_API_URL'])
15
+ @client.log_in ENV['MEDIAWIKI_USER'], ENV['MEDIAWIKI_PASSWORD']
16
16
 
17
17
  @client
18
18
  end