Class: Qualspec::Suite::Behavior

Inherits:
Object
  • Object
show all
Defined in:
lib/qualspec/suite/behavior.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Behavior

Returns a new instance of Behavior.



8
9
10
11
12
13
# File 'lib/qualspec/suite/behavior.rb', line 8

def initialize(name, &block)
  @name = name
  @scenarios_list = []

  instance_eval(&block) if block_given? # rubocop:disable Style/EvalWithLocation -- DSL pattern requires eval
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/qualspec/suite/behavior.rb', line 6

def name
  @name
end

#scenarios_listObject (readonly)

Returns the value of attribute scenarios_list.



6
7
8
# File 'lib/qualspec/suite/behavior.rb', line 6

def scenarios_list
  @scenarios_list
end

Class Method Details

.clear!Object



32
33
34
# File 'lib/qualspec/suite/behavior.rb', line 32

def clear!
  @registry = {}
end

.define(name, &block) ⇒ Object



24
25
26
# File 'lib/qualspec/suite/behavior.rb', line 24

def define(name, &block)
  registry[name.to_sym] = new(name, &block)
end

.find(name) ⇒ Object



28
29
30
# File 'lib/qualspec/suite/behavior.rb', line 28

def find(name)
  registry[name.to_sym] || raise(Qualspec::Error, "Behavior '#{name}' not found")
end

.registryObject



20
21
22
# File 'lib/qualspec/suite/behavior.rb', line 20

def registry
  @registry ||= {}
end

Instance Method Details

#scenario(name, &block) ⇒ Object



15
16
17
# File 'lib/qualspec/suite/behavior.rb', line 15

def scenario(name, &block)
  @scenarios_list << Scenario.new(name, &block)
end