Sha256: 367e74d12aa0d2f5f037e0b0381da1f4528e9480880c5bfc197f3e1818d9f31a

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

module Lucid
  class ContextLoader

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

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

      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

      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

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

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

      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
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid/results.rb
lucid-0.4.1 lib/lucid/results.rb
lucid-0.4.0 lib/lucid/results.rb