Class: Applitools::EyesBaseConfiguration

Inherits:
AbstractConfiguration show all
Defined in:
lib/applitools/core/eyes_base_configuration.rb

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'] || Applitools::Connectivity::ServerConnector::DEFAULT_SERVER_URL,
  api_key: ENV['APPLITOOLS_API_KEY'] || ENV['bamboo_APPLITOOLS_API_KEY'] || '',
  save_new_tests: true,
  default_match_settings: Applitools::ImageMatchSettings.new,
  accessibility_validation: nil,
  properties: []
}.freeze

Instance Attribute Summary

Attributes inherited from AbstractConfiguration

#config_hash, #validation_errors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractConfiguration

#deep_clone

Methods included from EyesConfigurationDSL

#accessor_methods, #boolean_field, #collect_method, #enum_field, #int_field, #methods_to_delegate, #object_field, #string_field

Constructor Details

#initializeEyesBaseConfiguration

Returns a new instance of EyesBaseConfiguration.



34
35
36
37
# File 'lib/applitools/core/eyes_base_configuration.rb', line 34

def initialize
  super
  # self.batch_info = Applitools::BatchInfo.new
end

Class Method Details

.default_configObject



29
30
31
# File 'lib/applitools/core/eyes_base_configuration.rb', line 29

def default_config
  DEFAULT_CONFIG
end

Instance Method Details

#add_property(name, value) ⇒ Object



173
174
175
# File 'lib/applitools/core/eyes_base_configuration.rb', line 173

def add_property(name, value)
  properties << { name: name, value: value } if name && value
end

#batchObject



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_keysObject



52
53
54
# File 'lib/applitools/core/eyes_base_configuration.rb', line 52

def config_keys
  config_hash.keys
end

#custom_getter_for_exact(_value) ⇒ Object



144
145
146
# File 'lib/applitools/core/eyes_base_configuration.rb', line 144

def custom_getter_for_exact(_value)
  default_match_settings.exact
end

#custom_getter_for_ignore_caret(_value) ⇒ Object



160
161
162
# File 'lib/applitools/core/eyes_base_configuration.rb', line 160

def custom_getter_for_ignore_caret(_value)
  default_match_settings.ignore_caret
end

#custom_getter_for_match_level(_value) ⇒ Object



156
157
158
# File 'lib/applitools/core/eyes_base_configuration.rb', line 156

def custom_getter_for_match_level(_value)
  default_match_settings.match_level
end

#custom_getter_for_remainder(_value) ⇒ Object



152
153
154
# File 'lib/applitools/core/eyes_base_configuration.rb', line 152

def custom_getter_for_remainder(_value)
  default_match_settings.remainder
end

#custom_getter_for_scale(_value) ⇒ Object



148
149
150
# File 'lib/applitools/core/eyes_base_configuration.rb', line 148

def custom_getter_for_scale(_value)
  default_match_settings.scale
end

#custom_setter_for_accessibility_validation(value) ⇒ Object



168
169
170
171
# File 'lib/applitools/core/eyes_base_configuration.rb', line 168

def custom_setter_for_accessibility_validation(value)
  # self.default_match_settings = self.parent.class.default_config[:default_match_settings] unless default_match_settings
  default_match_settings.accessibility_validation = value
end

#custom_setter_for_exact(value) ⇒ Object



128
129
130
# File 'lib/applitools/core/eyes_base_configuration.rb', line 128

def custom_setter_for_exact(value)
  default_match_settings.exact = value
end

#custom_setter_for_ignore_caret(value) ⇒ Object



164
165
166
# File 'lib/applitools/core/eyes_base_configuration.rb', line 164

def custom_setter_for_ignore_caret(value)
  default_match_settings.ignore_caret = value
end

#custom_setter_for_match_level(value) ⇒ Object



132
133
134
# File 'lib/applitools/core/eyes_base_configuration.rb', line 132

def custom_setter_for_match_level(value)
  default_match_settings.match_level = value
end

#custom_setter_for_remainder(value) ⇒ Object



140
141
142
# File 'lib/applitools/core/eyes_base_configuration.rb', line 140

def custom_setter_for_remainder(value)
  default_match_settings.remainder = value
end

#custom_setter_for_scale(value) ⇒ Object



136
137
138
# File 'lib/applitools/core/eyes_base_configuration.rb', line 136

def custom_setter_for_scale(value)
  default_match_settings.scale = value
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_proxy(uri, user = nil, password = nil) ⇒ Object



124
125
126
# File 'lib/applitools/core/eyes_base_configuration.rb', line 124

def set_proxy(uri, user = nil, password = nil)
  self.proxy = Applitools::Connectivity::Proxy.new(uri, user, password)
end

#short_descriptionObject



120
121
122
# File 'lib/applitools/core/eyes_base_configuration.rb', line 120

def short_description
  "#{test_name} of #{app_name}"
end

#to_sObject



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

Returns:

  • (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?
  # validation_errors[:viewport_size] = ':viewport_size is required' if viewport_size.square.zero?
  return true if validation_errors.keys.size.zero?
  false
end