Class: Cucumber::Runtime::Results

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Results

Returns a new instance of Results.



5
6
7
8
9
10
11
# File 'lib/cucumber/runtime/results.rb', line 5

def initialize(configuration)
  @configuration = configuration

  # Optimization - quicker lookup.
  @inserted_steps = {}
  @inserted_scenarios = {}
end

Instance Method Details

#configure(new_configuration) ⇒ Object



13
14
15
# File 'lib/cucumber/runtime/results.rb', line 13

def configure(new_configuration)
  @configuration = Configuration.parse(new_configuration)
end

#failure?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
# File 'lib/cucumber/runtime/results.rb', line 53

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

#scenario_visited(scenario) ⇒ Object

:nodoc:



26
27
28
29
30
31
32
33
# File 'lib/cucumber/runtime/results.rb', line 26

def scenario_visited(scenario) #:nodoc:
  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

:nodoc:



44
45
46
47
48
49
50
51
# File 'lib/cucumber/runtime/results.rb', line 44

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

#step_visited(step) ⇒ Object

:nodoc:



17
18
19
20
21
22
23
24
# File 'lib/cucumber/runtime/results.rb', line 17

def step_visited(step) #:nodoc:
  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:



35
36
37
38
39
40
41
42
# File 'lib/cucumber/runtime/results.rb', line 35

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