lapis_lazuli 0.8.9 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 775e67328e31c61c47ca10fb266c1a9df0f16767
4
- data.tar.gz: 62257d244b3d17da116336ca5a4f7b2c98c7f5d4
3
+ metadata.gz: 69ecad4834664da669d77a7df4e33aeaf78599f1
4
+ data.tar.gz: 8c8c532e1dcf5858a2d6a4e122b77596c50617dd
5
5
  SHA512:
6
- metadata.gz: 2c2ce085c18600b998f9c338137eeba49f92d42b6f13644994d826897d049881d7e9c87ca9d94249847e55edfdc3b9f0e6dc8f092decc6230f09b3faa0fd8ae4
7
- data.tar.gz: 0d567ffa3e99b58a305b4e25e52a27dbb9cd8bf71c941827ed664138d6b99dd54cc7019413ee77255cde1e276f220ca94e47ff8ff276afc584a8c9daa78069f8
6
+ metadata.gz: 0feef2515e1dd72ab4d7d815c0776a6feb1f05985eaf49f31fa1feb768c0e7e25f0a73af220b42ac2a50cea84a1beaf6c7f330c90cbb66923a5101f686ec1f96
7
+ data.tar.gz: 9957ee6a24b7c780527f6fa48e2f5a855d649c3a29e77aac292a3485bced58f1d0050cba7c22b1c1459d9bc645f4ec9c52280e70a6432bd551f38ce8a1730ce5
@@ -123,6 +123,8 @@ module LapisLazuli
123
123
  @browser = init(*args)
124
124
  # Add this browser to the list of all browsers
125
125
  LapisLazuli::Browser.add_browser(self)
126
+ # Making sure all browsers are gracefully closed when the exit event is triggered.
127
+ at_exit { LapisLazuli::Browser::close_all 'exit event trigger' }
126
128
  end
127
129
  end
128
130
 
@@ -168,20 +170,19 @@ module LapisLazuli
168
170
  def close_after_scenario(scenario)
169
171
  # Determine the config
170
172
  close_browser_after = world.env_or_config("close_browser_after")
171
-
172
173
  case close_browser_after
173
- when "scenario"
174
- # We always close it
175
- LapisLazuli::Browser.close_all close_browser_after
176
- when "never"
177
- # Do nothing: party time, excellent!
178
- when "end"
179
- # Also ignored here - this is handled in World.browser_destroy
180
- else
181
- if is_last_scenario?(scenario)
182
- # Close it
174
+ when "scenario"
175
+ # We always close it
183
176
  LapisLazuli::Browser.close_all close_browser_after
184
- end
177
+ when "never"
178
+ # Do nothing: party time, excellent!
179
+ when "feature"
180
+ if is_last_scenario?(scenario)
181
+ # Close it
182
+ LapisLazuli::Browser.close_all close_browser_after
183
+ end
184
+ else # close after 'end' is now default
185
+ # Also ignored here - this is handled in World.browser_destroy
185
186
  end
186
187
  end
187
188
 
@@ -230,125 +231,125 @@ module LapisLazuli
230
231
  end
231
232
 
232
233
  private
233
- ##
234
- # The main browser window for testing
235
- def init(browser_wanted=(no_browser_wanted=true;nil), optional_data=(no_optional_data=true;nil))
236
- # Store the optional data so on restart of the browser it still has the
237
- # correct configuration
238
- if no_optional_data and optional_data.nil? and @@cached_browser_options.has_key?(:optional_data) and (browser_wanted.nil? or browser_wanted == @@cached_browser_options[:browser])
239
- optional_data = @@cached_browser_options[:optional_data]
240
- elsif optional_data.nil?
241
- optional_data = {}
242
- end
243
-
244
- # Do the same caching stuff for the browser
245
- if no_browser_wanted and browser_wanted.nil? and @@cached_browser_options.has_key?(:browser)
246
- browser_wanted = @@cached_browser_options[:browser]
247
- end
234
+ ##
235
+ # The main browser window for testing
236
+ def init(browser_wanted=(no_browser_wanted=true; nil), optional_data=(no_optional_data=true; nil))
237
+ # Store the optional data so on restart of the browser it still has the
238
+ # correct configuration
239
+ if no_optional_data and optional_data.nil? and @@cached_browser_options.has_key?(:optional_data) and (browser_wanted.nil? or browser_wanted == @@cached_browser_options[:browser])
240
+ optional_data = @@cached_browser_options[:optional_data]
241
+ elsif optional_data.nil?
242
+ optional_data = {}
243
+ end
248
244
 
245
+ # Do the same caching stuff for the browser
246
+ if no_browser_wanted and browser_wanted.nil? and @@cached_browser_options.has_key?(:browser)
247
+ browser_wanted = @@cached_browser_options[:browser]
248
+ end
249
249
 
250
- if !@@cached_browser_options.has_key? :browser
251
- @@cached_browser_options[:browser] = browser_wanted
252
- # Duplicate the data as Webdriver modifies it
253
- @@cached_browser_options[:optional_data] = optional_data.dup
254
- end
255
250
 
256
- @browser_wanted = browser_wanted
257
- @optional_data = optional_data
258
- # Create the browser
259
- create_driver(@browser_wanted, @optional_data)
251
+ if !@@cached_browser_options.has_key? :browser
252
+ @@cached_browser_options[:browser] = browser_wanted
253
+ # Duplicate the data as Webdriver modifies it
254
+ @@cached_browser_options[:optional_data] = optional_data.dup
260
255
  end
261
256
 
262
- ##
263
- # Create a new browser depending on settings
264
- # Always cached the supplied arguments
265
- def create_driver(browser_wanted=nil, optional_data=nil)
266
- # Run-time dependency.
267
- begin
268
- require 'selenium-webdriver'
269
- require 'watir'
270
- rescue LoadError => err
271
- raise LoadError, "#{err}: you need to add 'watir' to your Gemfile before using the browser."
272
- end
257
+ @browser_wanted = browser_wanted
258
+ @optional_data = optional_data
259
+ # Create the browser
260
+ create_driver(@browser_wanted, @optional_data)
261
+ end
273
262
 
274
- # No browser? Does the config have a browser? Default to firefox
275
- if browser_wanted.nil?
276
- browser_wanted = world.env_or_config('browser', 'firefox')
277
- end
263
+ ##
264
+ # Create a new browser depending on settings
265
+ # Always cached the supplied arguments
266
+ def create_driver(browser_wanted=nil, optional_data=nil)
267
+ # Run-time dependency.
268
+ begin
269
+ require 'selenium-webdriver'
270
+ require 'watir'
271
+ rescue LoadError => err
272
+ raise LoadError, "#{err}: you need to add 'watir' to your Gemfile before using the browser."
273
+ end
278
274
 
279
- # Select the correct browser
280
- case browser_wanted.to_s.downcase
281
- when 'chrome'
282
- # Check Platform running script
283
- b = :chrome
284
- when 'safari'
285
- b = :safari
286
- when 'ie'
287
- require 'rbconfig'
288
- if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
289
- b = :ie
290
- else
291
- world.error("You can't run IE tests on non-Windows machine")
292
- end
293
- when 'ios'
294
- if RUBY_PLATFORM.downcase.include?("darwin")
295
- b = :iphone
296
- else
297
- world.error("You can't run IOS tests on non-mac machine")
298
- end
299
- when 'remote'
300
- b = :remote
301
- else
302
- b = :firefox
303
- end
275
+ # No browser? Does the config have a browser? Default to firefox
276
+ if browser_wanted.nil?
277
+ browser_wanted = world.env_or_config('browser', 'firefox')
278
+ end
304
279
 
305
- args = [b]
306
- @browser_name = b.to_s
307
- if b == :remote
308
- # Get the config
309
- remote_config = world.env_or_config("remote", {})
280
+ # Select the correct browser
281
+ case browser_wanted.to_s.downcase
282
+ when 'chrome'
283
+ # Check Platform running script
284
+ b = :chrome
285
+ when 'safari'
286
+ b = :safari
287
+ when 'ie'
288
+ require 'rbconfig'
289
+ if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
290
+ b = :ie
291
+ else
292
+ world.error("You can't run IE tests on non-Windows machine")
293
+ end
294
+ when 'ios'
295
+ if RUBY_PLATFORM.downcase.include?("darwin")
296
+ b = :iphone
297
+ else
298
+ world.error("You can't run IOS tests on non-mac machine")
299
+ end
300
+ when 'remote'
301
+ b = :remote
302
+ else
303
+ b = :firefox
304
+ end
310
305
 
311
- # The settings we are going to use to create the browser
312
- remote_settings = {}
306
+ args = [b]
307
+ @browser_name = b.to_s
308
+ if b == :remote
309
+ # Get the config
310
+ remote_config = world.env_or_config("remote", {})
313
311
 
314
- # Add the config to the settings using downcase string keys
315
- remote_config.each{|k,v| remote_settings[k.to_s.downcase] = v}
312
+ # The settings we are going to use to create the browser
313
+ remote_settings = {}
316
314
 
317
- if optional_data.is_a? Hash
318
- # Convert the optional data to downcase string keys
319
- string_hash = Hash.new
320
- optional_data.each{|k,v| string_hash[k.to_s.downcase] = v}
315
+ # Add the config to the settings using downcase string keys
316
+ remote_config.each { |k, v| remote_settings[k.to_s.downcase] = v }
321
317
 
322
- # Merge them with the settings
323
- remote_settings.merge! string_hash
324
- end
318
+ if optional_data.is_a? Hash
319
+ # Convert the optional data to downcase string keys
320
+ string_hash = Hash.new
321
+ optional_data.each { |k, v| string_hash[k.to_s.downcase] = v }
325
322
 
326
- args.push(remote_browser_config(remote_settings))
327
- elsif not optional_data.nil? and not optional_data.empty?
328
- world.log.debug("Got optional data: #{optional_data}")
329
- args.push(optional_data)
330
- elsif world.has_proxy?
331
- # Create a session if needed
332
- if !world.proxy.has_session?
333
- world.proxy.create()
334
- end
323
+ # Merge them with the settings
324
+ remote_settings.merge! string_hash
325
+ end
335
326
 
336
- proxy_url = "#{world.proxy.ip}:#{world.proxy.port}"
337
- if b == :firefox
338
- world.log.debug("Configuring Firefox proxy: #{proxy_url}")
339
- profile = Selenium::WebDriver::Firefox::Profile.new
340
- profile.proxy = Selenium::WebDriver::Proxy.new :http => proxy_url, :ssl => proxy_url
341
- args.push({:profile => profile})
342
- end
327
+ args.push(remote_browser_config(remote_settings))
328
+ elsif not optional_data.nil? and not optional_data.empty?
329
+ world.log.debug("Got optional data: #{optional_data}")
330
+ args.push(optional_data)
331
+ elsif world.has_proxy?
332
+ # Create a session if needed
333
+ if !world.proxy.has_session?
334
+ world.proxy.create()
343
335
  end
344
336
 
345
- begin
346
- browser_instance = Watir::Browser.new(*args)
347
- rescue Selenium::WebDriver::Error::UnknownError => err
348
- raise err
337
+ proxy_url = "#{world.proxy.ip}:#{world.proxy.port}"
338
+ if b == :firefox
339
+ world.log.debug("Configuring Firefox proxy: #{proxy_url}")
340
+ profile = Selenium::WebDriver::Firefox::Profile.new
341
+ profile.proxy = Selenium::WebDriver::Proxy.new :http => proxy_url, :ssl => proxy_url
342
+ args.push({:profile => profile})
349
343
  end
350
- return browser_instance
351
344
  end
345
+
346
+ begin
347
+ browser_instance = Watir::Browser.new(*args)
348
+ rescue Selenium::WebDriver::Error::UnknownError => err
349
+ raise err
350
+ end
351
+ return browser_instance
352
+ end
352
353
  end
353
354
 
354
355
  end
@@ -4,21 +4,6 @@ source 'http://rubygems.org'
4
4
  # install: --no-rdoc --no-ri
5
5
  # update: --no-rdoc --no-ri
6
6
 
7
- # Debuggers
8
- platforms :ruby_18, :ruby_19 do
9
- gem 'debugger'
10
- end
11
- platforms :ruby_20, :ruby_21 do
12
- gem 'byebug'
13
- gem 'rb-readline'
14
- end
15
-
16
- # Windows specific
17
- platforms :mswin, :mingw do
18
- gem 'win32console'
19
- gem 'term-ansicolor'
20
- end
21
-
22
7
  # Install all the webdriver gems and cucumber
23
8
  gem 'watir'
24
9
  gem 'cucumber'
@@ -9,7 +9,7 @@ module LapisLazuli
9
9
  ##
10
10
  # Configuration options and their default values
11
11
  CONFIG_OPTIONS = {
12
- "close_browser_after" => ["feature", "Close the browser after every scenario, feature, etc. Possible values are 'feature', 'scenario', 'end' and 'never'."],
12
+ "close_browser_after" => ["end", "Close the browser after every scenario, feature, etc. Possible values are 'feature', 'scenario', 'end' and 'never'."],
13
13
  "error_strings" => [nil, "List of strings that indicate errors when detected on a web page."],
14
14
  "default_env" => [nil, "Indicates which environment specific configuration to load when no test environment is provided explicitly."],
15
15
  "test_env" => [nil, "Indicates which environment specific configuration to load in this test run."],
@@ -6,5 +6,5 @@
6
6
  # All rights reserved.
7
7
  #
8
8
  module LapisLazuli
9
- VERSION = "0.8.9"
9
+ VERSION = "0.9.0"
10
10
  end
@@ -61,8 +61,8 @@ module WorldModule
61
61
  "browser",
62
62
  {
63
63
  "name" => brow.driver.capabilities[:browser_name],
64
- "version" => brow.driver.capabilities[:version],
65
- "platform" => brow.driver.capabilities[:platform],
64
+ "version" => brow.driver.capabilities[:browser_version] || brow.driver.capabilities[:version],
65
+ "platform" => brow.driver.capabilities[:platform_name] || brow.driver.capabilities[:platform],
66
66
  }
67
67
  )
68
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lapis_lazuli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onno Steenbergen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-01-26 00:00:00.000000000 Z
14
+ date: 2017-02-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler