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.



233
234
235
236
237
238
# File 'lib/cucumber/core/test/result.rb', line 233

def initialize(strict_types = [])
  @settings = Hash[STRICT_AFFECTED_TYPES.map { |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.



230
231
232
# File 'lib/cucumber/core/test/result.rb', line 230

def settings=(value)
  @settings = value
end

Instance Method Details

#merge!(other) ⇒ Object



263
264
265
266
267
268
# File 'lib/cucumber/core/test/result.rb', line 263

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

#set?(type) ⇒ Boolean

Returns:

  • (Boolean)


270
271
272
# File 'lib/cucumber/core/test/result.rb', line 270

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

#set_strict(setting, type = nil) ⇒ Object



253
254
255
256
257
258
259
260
261
# File 'lib/cucumber/core/test/result.rb', line 253

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)


240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/cucumber/core/test/result.rb', line 240

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