Class: Lucid::ContextLoader::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/lucid/results.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Results

Returns a new instance of Results.



5
6
7
8
9
# File 'lib/lucid/results.rb', line 5

def initialize(context)
  @context = context
  @inserted_steps = {}
  @inserted_scenarios = {}
end

Instance Method Details

#configure(new_context) ⇒ Object



11
12
13
# File 'lib/lucid/results.rb', line 11

def configure(new_context)
  @context = Context.parse(new_context)
end

#failure?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
# File 'lib/lucid/results.rb', line 51

def failure?
  if @context.wip?
    scenarios(:passed).any?
  else
    scenarios(:failed).any? || steps(:failed).any? ||
    (@context.strict? && (steps(:undefined).any? || steps(:pending).any?))
  end
end

#scenario_visited(scenario) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/lucid/results.rb', line 24

def scenario_visited(scenario)
  scenario_id = scenario.object_id

  unless @inserted_scenarios.has_key?(scenario_id)
    @inserted_scenarios[scenario_id] = scenario
    scenarios.push(scenario)
  end
end

#scenarios(status = nil) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/lucid/results.rb', line 42

def scenarios(status = nil)
  @scenarios ||= []
  if(status)
    @scenarios.select{|scenario| scenario.status == status}
  else
    @scenarios
  end
end

#step_visited(step) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/lucid/results.rb', line 15

def step_visited(step)
  step_id = step.object_id

  unless @inserted_steps.has_key?(step_id)
    @inserted_steps[step_id] = step
    steps.push(step)
  end
end

#steps(status = nil) ⇒ Object

:nodoc:



33
34
35
36
37
38
39
40
# File 'lib/lucid/results.rb', line 33

def steps(status = nil) #:nodoc:
  @steps ||= []
  if(status)
    @steps.select{|step| step.status == status}
  else
    @steps
  end
end