Sha256: e58be8f60e0060daecfd9e7cf6f2b9188428d102a26eeefffd6895b38a48078f

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

module Lucid
  class Runtime

    class Results
      def initialize(configuration)
        @configuration = configuration

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

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

      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

      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

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

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

      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
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lucid-0.2.1 lib/lucid/runtime/results.rb
lucid-0.2.0 lib/lucid/runtime/results.rb
lucid-0.1.1 lib/lucid/runtime/results.rb
lucid-0.1.0 lib/lucid/runtime/results.rb
lucid-0.0.9 lib/lucid/runtime/results.rb
lucid-0.0.8 lib/lucid/runtime/results.rb
lucid-0.0.7 lib/lucid/runtime/results.rb
lucid-0.0.6 lib/lucid/runtime/results.rb
lucid-0.0.5 lib/lucid/runtime/results.rb