Module: Lucid::Interface::InterfaceMethods

Included in:
Lucid::InterfaceRb::RbLanguage
Defined in:
lib/lucid/interface.rb

Instance Method Summary collapse

Instance Method Details

#add_hook(phase, hook) ⇒ Object



46
47
48
49
# File 'lib/lucid/interface.rb', line 46

def add_hook(phase, hook)
  hooks[phase.to_sym] << hook
  hook
end

#add_transform(transform) ⇒ Object



55
56
57
58
# File 'lib/lucid/interface.rb', line 55

def add_transform(transform)
  transforms.unshift transform
  transform
end

#after(scenario) ⇒ Object



22
23
24
25
# File 'lib/lucid/interface.rb', line 22

def after(scenario)
  execute_after(scenario)
  end_scenario
end

#after_configuration(configuration) ⇒ Object



27
28
29
30
31
# File 'lib/lucid/interface.rb', line 27

def after_configuration(configuration)
  hooks[:after_configuration].each do |hook|
    hook.invoke('AfterConfiguration', configuration)
  end
end

#around(scenario) ⇒ Object



11
12
13
14
15
# File 'lib/lucid/interface.rb', line 11

def around(scenario)
  execute_around(scenario) do
    yield
  end
end

#available_step_definition(regexp_source, file_colon_line) ⇒ Object



68
69
70
# File 'lib/lucid/interface.rb', line 68

def available_step_definition(regexp_source, file_colon_line)
  available_step_definition_hash[StepDefinitionUsage.new(regexp_source, file_colon_line)] = nil
end

#before(scenario) ⇒ Object



17
18
19
20
# File 'lib/lucid/interface.rb', line 17

def before(scenario)
  begin_scenario(scenario)
  execute_before(scenario)
end

#clear_hooksObject



51
52
53
# File 'lib/lucid/interface.rb', line 51

def clear_hooks
  @hooks = nil
end

#execute_after_step(scenario) ⇒ Object



33
34
35
36
37
# File 'lib/lucid/interface.rb', line 33

def execute_after_step(scenario)
  hooks_for(:after_step, scenario).each do |hook|
    invoke(hook, 'AfterStep', scenario, false)
  end
end

#execute_transforms(args) ⇒ Object



39
40
41
42
43
44
# File 'lib/lucid/interface.rb', line 39

def execute_transforms(args)
  args.map do |arg|
    matching_transform = transforms.detect {|transform| transform.match(arg) }
    matching_transform ? matching_transform.invoke(arg) : arg
  end
end

#hooks_for(phase, scenario) ⇒ Object

:nodoc:



60
61
62
# File 'lib/lucid/interface.rb', line 60

def hooks_for(phase, scenario) #:nodoc:
  hooks[phase.to_sym].select{|hook| scenario.accept_hook?(hook)}
end

#invoked_step_definition(regexp_source, file_colon_line) ⇒ Object



72
73
74
# File 'lib/lucid/interface.rb', line 72

def invoked_step_definition(regexp_source, file_colon_line)
  invoked_step_definition_hash[StepDefinitionUsage.new(regexp_source, file_colon_line)] = nil
end

#unmatched_step_definitionsObject



64
65
66
# File 'lib/lucid/interface.rb', line 64

def unmatched_step_definitions
  available_step_definition_hash.keys - invoked_step_definition_hash.keys
end