Class: Applitools::EyesBaseConfiguration
Constant Summary
collapse
- DEFAULT_CONFIG =
{
branch_name: ENV['APPLITOOLS_BRANCH'] || '',
parent_branch_name: ENV['APPLITOOLS_PARENT_BRANCH'] || '',
baseline_branch_name: ENV['APPLITOOLS_BASELINE_BRANCH'] || '',
save_diffs: false,
server_url: ENV['APPLITOOLS_SERVER_URL'] ||
ENV['bamboo_APPLITOOLS_SERVER_URL'] || 'https://eyessdk.applitools.com',
api_key: ENV['APPLITOOLS_API_KEY'] || ENV['bamboo_APPLITOOLS_API_KEY'] || '',
match_level: Applitools::MatchLevel::STRICT,
scale: 0,
remainder: 0,
save_new_tests: true
}.freeze
Instance Attribute Summary
#config_hash, #validation_errors
Class Method Summary
collapse
Instance Method Summary
collapse
#match_level_with_exact
#deep_clone
#accessor_methods, #boolean_field, #collect_method, #enum_field, #int_field, #methods_to_delegate, #object_field, #string_field
Constructor Details
Returns a new instance of EyesBaseConfiguration.
34
35
36
37
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 34
def initialize
super
end
|
Class Method Details
.default_config ⇒ Object
29
30
31
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 29
def default_config
DEFAULT_CONFIG
end
|
Instance Method Details
#batch ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 75
def batch
if batch_info.nil?
Applitools::EyesLogger.info 'No batch set'
self.batch_info = BatchInfo.new
end
batch_info
end
|
#batch=(value) ⇒ Object
83
84
85
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 83
def batch=(value)
self.batch_info = value
end
|
#config_keys ⇒ Object
52
53
54
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 52
def config_keys
config_hash.keys
end
|
#default_match_settings ⇒ Object
150
151
152
153
154
155
156
157
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 150
def default_match_settings
{
match_level: match_level,
exact: exact,
scale: scale,
remainder: remainder
}
end
|
#default_match_settings=(value) ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 135
def default_match_settings=(value)
Applitools::ArgumentGuard.is_a? value, 'value', Hash
= value.keys - match_level_keys
unless .empty?
raise Applitools::EyesIllegalArgument.new(
"Pasiing extra keys is prohibited! Passed extra keys: #{}"
)
end
result = default_match_settings.merge!(value)
(self.match_level, self.exact) = match_level_with_exact(result[:match_level], result[:exact])
self.scale = result[:scale]
self.remainder = result[:remainder]
result
end
|
#match_level=(value) ⇒ Object
#match_level_keys ⇒ Object
159
160
161
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 159
def match_level_keys
%w(match_level exact scale remainder).map(&:to_sym)
end
|
#merge(other_config) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 39
def merge(other_config)
return if object_id == other_config.object_id
(config_keys + other_config. config_keys).uniq do |k|
merge_key(other_config, k)
end
end
|
#merge_key(other_config, key) ⇒ Object
46
47
48
49
50
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 46
def merge_key(other_config, key)
return unless other_config.send("defined_#{key}?")
return unless respond_to?("#{key}=")
send("#{key}=", other_config.send(key))
end
|
#set_default_match_settings(value, exact_options = {}) ⇒ Object
131
132
133
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 131
def set_default_match_settings(value, exact_options = {})
(self.match_level, self.exact) = match_level_with_exact(value, exact_options)
end
|
#set_proxy(uri, user = nil, password = nil) ⇒ Object
120
121
122
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 120
def set_proxy(uri, user = nil, password = nil)
self.proxy = Applitools::Connectivity::Proxy.new(uri, user, password)
end
|
#short_description ⇒ Object
116
117
118
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 116
def short_description
"#{test_name} of #{app_name}"
end
|
#to_s ⇒ Object
56
57
58
59
60
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 56
def to_s
config_keys.map do |k|
"#{k} = #{send(k)}"
end.join("\n")
end
|
#valid? ⇒ Boolean
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/applitools/core/eyes_base_configuration.rb', line 62
def valid?
validation_errors.clear
validation_errors[:app_name] = ':app_name is required' unless app_name
validation_errors[:test_name] = ':test_name is required' unless test_name
validation_errors[:app_name] = ':app_name is required' if app_name && app_name.empty?
validation_errors[:test_name] = ':test_name is required' if test_name && test_name.empty?
return true if validation_errors.keys.size.zero?
false
end
|