Sha256: 8f7bf809dedcf1e22d426ca1dd45383da0f8f93a78e41dc727b111bef5eee054

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class BisectionProgress
  attr_reader :iteration, :enabled_examples, :total_examples, :start_time

  def initialize(attributes = {})
    @iteration = attributes.fetch(:iteration) { 1 }
    @enabled_examples = attributes.fetch(:enabled_examples)
    @total_examples = attributes.fetch(:total_examples)
    @time_provider = attributes.fetch(:time_provider) { Time }
    @start_time = attributes.fetch(:start_time) { @time_provider.now }
  end

  def next_iteration(enabled_examples)
    self.class.new(iteration: iteration + 1,
                   enabled_examples: enabled_examples,
                   total_examples: total_examples,
                   time_provider: @time_provider,
                   start_time: start_time)
  end

  def run_time
    @time_provider.now - @start_time
  end

  def ==(other)
    values.map do |v|
      self.send(v) == other.send(v)
    end.all?
  end

  def hash
    values.map do |v|
      self.send(v).hash
    end.reduce(:^)
  end

  private

  def values
    [:iteration, :enabled_examples, :total_examples]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-search-and-destroy-0.0.4 lib/rspec-search-and-destroy/bisection_progress.rb