Class: Cucumber::Core::Test::Result::StrictConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/test/result.rb

Overview

Handles the strict settings for the result types that are affected by the strict options (that is the STRICT_AFFECTED_TYPES).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strict_types = []) ⇒ StrictConfiguration

Returns a new instance of StrictConfiguration.



288
289
290
291
292
293
# File 'lib/cucumber/core/test/result.rb', line 288

def initialize(strict_types = [])
  @settings = STRICT_AFFECTED_TYPES.to_h { |t| [t, :default] }
  strict_types.each do |type|
    set_strict(true, type)
  end
end

Instance Attribute Details

#settings=(value) ⇒ Object

Sets the attribute settings

Parameters:

  • value

    the value to set the attribute settings to.



285
286
287
# File 'lib/cucumber/core/test/result.rb', line 285

def settings=(value)
  @settings = value
end

Instance Method Details

#merge!(other) ⇒ Object



317
318
319
320
321
322
# File 'lib/cucumber/core/test/result.rb', line 317

def merge!(other)
  settings.each_key do |type|
    set_strict(other.strict?(type), type) if other.set?(type)
  end
  self
end

#set?(type) ⇒ Boolean

Returns:

  • (Boolean)


324
325
326
# File 'lib/cucumber/core/test/result.rb', line 324

def set?(type)
  settings[type] != :default
end

#set_strict(setting, type = nil) ⇒ Object



309
310
311
312
313
314
315
# File 'lib/cucumber/core/test/result.rb', line 309

def set_strict(setting, type = nil)
  if type.nil?
    STRICT_AFFECTED_TYPES.each { |type| set_strict(setting, type) }
  else
    settings[type] = setting
  end
end

#strict?(type = nil) ⇒ Boolean

Returns:

  • (Boolean)


295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/cucumber/core/test/result.rb', line 295

def strict?(type = nil)
  if type.nil?
    settings.each_value do |value|
      return true if value == true
    end
    false
  else
    return false unless settings.key?(type)
    return false unless set?(type)

    settings[type]
  end
end