unobtainium 0.2.0 → 0.2.1

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: 62f55e229f2458af4e265380afd8e407135e2f6e
4
- data.tar.gz: 84c5321fff693ec7eedddc59f74bbe829303f383
3
+ metadata.gz: 234ce137a967d3cbf7343bc5dce74f6a3a606339
4
+ data.tar.gz: 4bd93c4402adf6a379f1037b70958941018e805f
5
5
  SHA512:
6
- metadata.gz: 070ff928ed2373b5f26bcb9d4c596d6d7ced6443d0028feeaba897a1cb66accec60b8612204245ef9c76dc00213bab8c0c9ea0562483d286d7d3524926536781
7
- data.tar.gz: 2c8b4a547d1cc410d60f0d0d86c214720097f1da2ea7a4d1717d7b1645615be12add8ccfac7eac53f1e091e4c8ef32ef28b8672f1366d7db87ebffad32acf4a5
6
+ metadata.gz: 7899a9aefc8410150b42f930d8a770fff850883284026551b25edd9e30bdf152117b5510e88e192b2e21b097346e5cc8e773ee2bdbe945bf5a72a4641032e683
7
+ data.tar.gz: f718847acf4c4600caa0f5a7b37dd76c0e5cf468b3d1993582aae3bdfbb2092d4fcc94ece7942c6e906029dbc0cf825a6dc491438981b68c140634be9a3c4846
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unobtainium (0.2.0)
4
+ unobtainium (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,6 +6,9 @@
6
6
  # Copyright (c) 2016 Jens Finkhaeuser and other unobtainium contributors.
7
7
  # All rights reserved.
8
8
  #
9
+
10
+ require_relative './support/util'
11
+
9
12
  module Unobtainium
10
13
  module Drivers
11
14
 
@@ -31,6 +34,8 @@ module Unobtainium
31
34
  }.freeze
32
35
 
33
36
  class << self
37
+ include ::Unobtainium::Drivers::Utility
38
+
34
39
  ##
35
40
  # Return true if the given label matches this driver implementation,
36
41
  # false otherwise.
@@ -84,17 +89,6 @@ module Unobtainium
84
89
 
85
90
  private
86
91
 
87
- ##
88
- # For a recognized label alias, returns a normalized label.
89
- def normalize_label(label)
90
- LABELS.each do |normalized, aliases|
91
- if label == normalized or aliases.include?(label)
92
- return normalized
93
- end
94
- end
95
- return nil
96
- end
97
-
98
92
  ##
99
93
  # If the driver options include a request for a browser, we can
100
94
  # supplement some missing specs in the options.
@@ -6,6 +6,9 @@
6
6
  # Copyright (c) 2016 Jens Finkhaeuser and other unobtainium contributors.
7
7
  # All rights reserved.
8
8
  #
9
+
10
+ require_relative './support/util'
11
+
9
12
  module Unobtainium
10
13
  module Drivers
11
14
 
@@ -23,6 +26,8 @@ module Unobtainium
23
26
  }.freeze
24
27
 
25
28
  class << self
29
+ include ::Unobtainium::Drivers::Utility
30
+
26
31
  ##
27
32
  # Return true if the given label matches this driver implementation,
28
33
  # false otherwise.
@@ -62,19 +67,6 @@ module Unobtainium
62
67
  driver = ::Selenium::WebDriver.for(normalize_label(label), options)
63
68
  return driver
64
69
  end
65
-
66
- private
67
-
68
- ##
69
- # For a recognized label alias, returns a normalized label.
70
- def normalize_label(label)
71
- LABELS.each do |normalized, aliases|
72
- if label == normalized or aliases.include?(label)
73
- return normalized
74
- end
75
- end
76
- return nil
77
- end
78
70
  end # class << self
79
71
  end # class Selenium
80
72
 
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ #
3
+ # unobtainium
4
+ # https://github.com/jfinkhaeuser/unobtainium
5
+ #
6
+ # Copyright (c) 2016 Jens Finkhaeuser and other unobtainium contributors.
7
+ # All rights reserved.
8
+ #
9
+ module Unobtainium
10
+ module Drivers
11
+ ##
12
+ # Utility code shared by driver implementations
13
+ module Utility
14
+ ##
15
+ # For a recognized label alias, returns a normalized label. Requires
16
+ # the enclosing class to provide a LABELS connstant that is a hash
17
+ # where keys are the normalized label, and the value is an array of
18
+ # aliases:
19
+ #
20
+ # LABELS = {
21
+ # foo: [:alias1, :alias2],
22
+ # bar: [],
23
+ # }.freeze
24
+ #
25
+ # Empty aliases means that there are no aliases for this label.
26
+ def normalize_label(label)
27
+ self::LABELS.each do |normalized, aliases|
28
+ if label == normalized or aliases.include?(label)
29
+ return normalized
30
+ end
31
+ end
32
+ return nil
33
+ end
34
+ end # module Utility
35
+ end # module Drivers
36
+ end # module Unobtainium
@@ -7,5 +7,5 @@
7
7
  # All rights reserved.
8
8
  #
9
9
  module Unobtainium
10
- VERSION = "0.2.0".freeze
10
+ VERSION = "0.2.1".freeze
11
11
  end
@@ -57,6 +57,12 @@ module Unobtainium
57
57
  # we need to use.
58
58
  if not options.nil? and not options["base"].nil?
59
59
  label = options["base"]
60
+
61
+ # Unfortunately, the "base" key may not be recognized by the drivers,
62
+ # which could lead to errors down the road. Let's remove it; it's reserved
63
+ # by the Config class, so drivers can't use it anyhow.
64
+ options = options.dup
65
+ options.delete("base")
60
66
  end
61
67
 
62
68
  # The driver may modify the options; if so, we should let it do that
data/spec/config_spec.rb CHANGED
@@ -105,4 +105,15 @@ describe ::Unobtainium::Config do
105
105
  expect(cfg["drivers.branch2.base"]).to eql 'mock'
106
106
  expect(cfg["drivers.leaf.base"]).to eql 'mock'
107
107
  end
108
+
109
+ it "extends configuration hashes when the base does not exist" do
110
+ config = File.join(@data_path, 'driverconfig.yml')
111
+ cfg = ::Unobtainium::Config.load_config(config)
112
+
113
+ # Ensure the hash contains its own value
114
+ expect(cfg["drivers.base_does_not_exist.some"]).to eql "value"
115
+
116
+ # Also ensure the "base" is set properly
117
+ expect(cfg["drivers.base_does_not_exist.base"]).to eql "nonexistent_base"
118
+ end
108
119
  end
@@ -20,4 +20,7 @@ drivers:
20
20
  extends: branch2
21
21
  leafoption: baz
22
22
  branch1option: override
23
+ base_does_not_exist:
24
+ extends: nonexistent_base
25
+ some: value
23
26
  driver: leaf
data/spec/world_spec.rb CHANGED
@@ -31,7 +31,8 @@ describe ::Unobtainium::World do
31
31
  expect(@tester.driver.passed_options["mockoption"]).to eql 42
32
32
  end
33
33
 
34
- it "extends driver options" do
35
- expect(@tester.driver.passed_options["base"]).to eql "mock"
34
+ it "extends driver options, but doesn't pass 'base' on" do
35
+ expect(@tester.config["drivers.leaf.base"]).to eql "mock"
36
+ expect(@tester.driver.passed_options["base"]).to be_nil
36
37
  end
37
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unobtainium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Finkhaeuser
@@ -112,6 +112,7 @@ files:
112
112
  - lib/unobtainium/driver.rb
113
113
  - lib/unobtainium/drivers/appium.rb
114
114
  - lib/unobtainium/drivers/selenium.rb
115
+ - lib/unobtainium/drivers/support/util.rb
115
116
  - lib/unobtainium/pathed_hash.rb
116
117
  - lib/unobtainium/recursive_merge.rb
117
118
  - lib/unobtainium/runtime.rb