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
}.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.



32
33
34
35
# File 'lib/applitools/core/eyes_base_configuration.rb', line 32

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

Class Method Details

.default_configObject



27
28
29
# File 'lib/applitools/core/eyes_base_configuration.rb', line 27

def default_config
  DEFAULT_CONFIG
end

Instance Method Details

#batchObject



73
74
75
76
77
78
79
# File 'lib/applitools/core/eyes_base_configuration.rb', line 73

def batch
  if batch_info.nil?
    Applitools::EyesLogger.info 'No batch set'
    self.batch_info = BatchInfo.new
  end
  batch_info
end

#batch=(value) ⇒ Object



81
82
83
# File 'lib/applitools/core/eyes_base_configuration.rb', line 81

def batch=(value)
  self.batch_info = value
end

#config_keysObject



50
51
52
# File 'lib/applitools/core/eyes_base_configuration.rb', line 50

def config_keys
  config_hash.keys
end

#custom_getter_for_exact(_value) ⇒ Object



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

def custom_getter_for_exact(_value)
  default_match_settings.exact
end

#custom_getter_for_match_level(_value) ⇒ Object



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

def custom_getter_for_match_level(_value)
  default_match_settings.match_level
end

#custom_getter_for_remainder(_value) ⇒ Object



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

def custom_getter_for_remainder(_value)
  default_match_settings.remainder
end

#custom_getter_for_scale(_value) ⇒ Object



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

def custom_getter_for_scale(_value)
  default_match_settings.scale
end

#custom_setter_for_exact(value) ⇒ Object



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

def custom_setter_for_exact(value)
  default_match_settings.exact = value
end

#custom_setter_for_match_level(value) ⇒ Object



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

def custom_setter_for_match_level(value)
  default_match_settings.match_level = value
end

#custom_setter_for_remainder(value) ⇒ Object



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

def custom_setter_for_remainder(value)
  default_match_settings.remainder = value
end

#custom_setter_for_scale(value) ⇒ Object



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

def custom_setter_for_scale(value)
  default_match_settings.scale = value
end

#merge(other_config) ⇒ Object



37
38
39
40
41
42
# File 'lib/applitools/core/eyes_base_configuration.rb', line 37

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



44
45
46
47
48
# File 'lib/applitools/core/eyes_base_configuration.rb', line 44

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



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

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

#short_descriptionObject



115
116
117
# File 'lib/applitools/core/eyes_base_configuration.rb', line 115

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

#to_sObject



54
55
56
57
58
# File 'lib/applitools/core/eyes_base_configuration.rb', line 54

def to_s
  config_keys.map do |k|
    "#{k} = #{send(k)}"
  end.join("\n")
end

#valid?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/applitools/core/eyes_base_configuration.rb', line 60

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