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: 'https://eyessdk.applitools.com',
  api_key: ENV['APPLITOOLS_API_KEY'] || ''
}.freeze

Instance Attribute Summary

Attributes inherited from AbstractConfiguration

#config_hash, #validation_errors

Class Method Summary collapse

Instance Method Summary collapse

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.



23
24
25
26
# File 'lib/applitools/core/eyes_base_configuration.rb', line 23

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

Class Method Details

.default_configObject



18
19
20
# File 'lib/applitools/core/eyes_base_configuration.rb', line 18

def default_config
  DEFAULT_CONFIG
end

Instance Method Details

#batchObject



64
65
66
67
68
69
70
# File 'lib/applitools/core/eyes_base_configuration.rb', line 64

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

#batch=(value) ⇒ Object



72
73
74
# File 'lib/applitools/core/eyes_base_configuration.rb', line 72

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

#config_keysObject



41
42
43
# File 'lib/applitools/core/eyes_base_configuration.rb', line 41

def config_keys
  config_hash.keys
end

#merge(other_config) ⇒ Object



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

def merge(other_config)
  return if self.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



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

def merge_key(other_config, key)
  return unless other_config.send("defined_#{key}?")
  return unless self.respond_to? "#{key}="
  self.send("#{key}=", other_config.send(key))
end

#short_descriptionObject



100
101
102
# File 'lib/applitools/core/eyes_base_configuration.rb', line 100

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

#to_sObject



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

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

#valid?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/applitools/core/eyes_base_configuration.rb', line 51

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