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.



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

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.



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

def settings=(value)
  @settings = value
end

Instance Method Details

#merge!(other) ⇒ Object



320
321
322
323
324
325
# File 'lib/cucumber/core/test/result.rb', line 320

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)


327
328
329
# File 'lib/cucumber/core/test/result.rb', line 327

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

#set_strict(setting, type = nil) ⇒ Object



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

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

#strict?(type = nil) ⇒ Boolean

Returns:

  • (Boolean)


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

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

    settings[type]
  end
end