lapis_lazuli 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,140 +0,0 @@
1
- #
2
- # LapisLazuli
3
- # https://github.com/spriteCloud/lapis-lazuli
4
- #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
6
- # All rights reserved.
7
- #
8
-
9
- module LapisLazuli
10
- module BrowserModule
11
- module Remote
12
- # Convert settings to a valid remote driver argument
13
- #
14
- # Features:
15
- # - settings hash can be case insensitive "URL","Url", "url"
16
- # - caps.firefox_profile will be converted to a Selenium::WebDriver::Firefox::Profile
17
- # - caps.proxy / caps.firefox_profile.proxy will be converted to a Selenium::WebDriver::Proxy
18
- # - Hashes can have a String or a Symbol as key
19
- #
20
- # Example:
21
- # args = remote_browser_config(
22
- # {
23
- # "url"=>"http://test.com",
24
- # "user"=>"user21",
25
- # "password"=>"jehwiufhewuf",
26
- # "caps"=> {
27
- # "browser_name"=>"firefox",
28
- # "version"=>"37",
29
- # "firefox_profile"=>{
30
- # "plugin.state.flash"=>0,
31
- # "secure_ssl"=>true,
32
- # "proxy"=>{"http"=>"test.com:9000"}
33
- # },
34
- # "proxy"=>{:http=>"test.com:7000"},
35
- # :css_selectors_enabled => true
36
- # }
37
- # })
38
- # Watir::Browser.new :remote, args
39
- def remote_browser_config(settings)
40
- require "uri"
41
- require "selenium-webdriver"
42
-
43
- if !settings.is_a? Hash
44
- world.error("Missing Remote Browser Settings")
45
- end
46
-
47
- # Fetch the URl
48
- url = hash_get_case_insensitive(settings,"url")
49
-
50
- # Test if its a valid URL
51
- if not (url.to_s =~ /\A#{URI::regexp(["http", "https"])}\z/)
52
- raise "Incorrect Remote URL: '#{url.to_s}'"
53
- end
54
-
55
- # Create URI object
56
- uri = URI.parse(url)
57
-
58
- # Add user if needed
59
- user = hash_get_case_insensitive(settings,"user")
60
- if !user.nil?
61
- uri.user = user
62
- end
63
-
64
- # Add password if needed
65
- password = hash_get_case_insensitive(settings,"password")
66
- if !password.nil?
67
- uri.password = password
68
- end
69
-
70
- # Create capabil
71
- # Check ities
72
- caps = Selenium::WebDriver::Remote::Capabilities.new
73
- # Fetch the settings
74
- caps_settings = hash_get_case_insensitive(settings,"caps")
75
-
76
- # If we have settings
77
- if !caps_settings.nil? and caps_settings.is_a? Hash
78
- caps_settings.each do |key, val|
79
- # Convert to proxy
80
- if key.to_s == "proxy"
81
- set_proxy(caps, val)
82
- # Convert to FF profile
83
- elsif key.to_s == "firefox_profile"
84
- profile = Selenium::WebDriver::Firefox::Profile.new
85
- # Set all the options
86
- val.each do |fkey, fval|
87
- # Convert to proxy
88
- if fkey.to_s == "proxy"
89
- set_proxy(profile,fval)
90
- else
91
- set_key(profile, fkey, fval)
92
- end
93
- end
94
- # Set the profile
95
- caps[:firefox_profile] = profile
96
- else
97
- # Use set_key to assign the key
98
- set_key(caps, key, val)
99
- end
100
- end
101
- end
102
-
103
- world.log.debug("Using remote browser: #{url} (#{uri.user}) #{caps.to_json}")
104
-
105
- return {
106
- :url => uri.to_s,
107
- :desired_capabilities => caps
108
- }
109
- end
110
-
111
- private
112
- def hash_get_case_insensitive(hash, key)
113
- new_key = hash.keys.find {|e| e.to_s.casecmp(key.to_s) == 0}
114
- if new_key.nil?
115
- return nil
116
- end
117
- return hash[new_key]
118
- end
119
-
120
- # Sets a selenium proxy to the object
121
- def set_proxy(object, hash)
122
- proxy = Selenium::WebDriver::Proxy.new
123
- hash.each do |key, val|
124
- set_key(proxy, key, val)
125
- end
126
- object.proxy = proxy
127
- end
128
-
129
- # Uses function based on key or key itself to store the value in the object
130
- def set_key(object, key, val)
131
- if object.respond_to? "#{key}="
132
- object.send("#{key}=", val)
133
- else
134
- object[key] = val
135
- end
136
- end
137
-
138
- end # module Remote
139
- end # module BrowserModule
140
- end # module LapisLazuli
@@ -1,47 +0,0 @@
1
- #
2
- # LapisLazuli
3
- # https://github.com/spriteCloud/lapis-lazuli
4
- #
5
- # Copyright (c) 2013-2017 spriteCloud B.V. and other LapisLazuli contributors.
6
- # All rights reserved.
7
- #
8
-
9
- require 'json'
10
-
11
- require 'lapis_lazuli/argparse'
12
-
13
- module LapisLazuli
14
- module WorldModule
15
- ##
16
- # Module with annotation related functionality
17
- #
18
- # Annotations are embedded into the report via cucumber's embed function, and
19
- # that means they're embedded at the step level.
20
- #
21
- # They're also stored at scenario scope, so one step in a scenario can access
22
- # annotations made in another step.
23
- module Annotate
24
-
25
- include LapisLazuli::ArgParse
26
-
27
- def annotate(*args)
28
- @annotations ||= {}
29
-
30
- scope = scenario.scope(true) || 'items'
31
- stuff = parse_args({}, scope, *args)
32
-
33
- for_scope = @annotations.fetch(scope, [])
34
- for_scope << stuff[scope]
35
- @annotations[scope] = for_scope
36
-
37
- if self.respond_to? "embed"
38
- embed(JSON.generate(stuff), 'application/json')
39
- end
40
- end
41
-
42
- def annotations
43
- @annotations
44
- end
45
- end # module Annotate
46
- end # module WorldModule
47
- end # module LapisLazuli
@@ -1,23 +0,0 @@
1
- @annotation @p
2
- Feature: annotiations
3
- When I want to test the Lapis Lazuli library
4
- I want to run a webserver with some test files
5
- And execute the each library function that handles annotations.
6
-
7
- @annotation_01
8
- Scenario Outline: annotation_01 - scenario outline
9
- Given I annotate a step with <data1>
10
- And I annotate a step with <data2>
11
- Then the report should include <data1> and <data2> in the correct place
12
-
13
- Examples:
14
- | data1 | data2 |
15
- | foo | bar |
16
- | foo | |
17
- | | bar |
18
-
19
- @annotation_02
20
- Scenario: annotation_01 - single scenario
21
- Given I annotate a step with baz
22
- And I annotate a step with quux
23
- Then the report should include baz and quux in the correct place