Sha256: 3bad42a35fb7824b17a0dffb702a41531536f724807cf34666f36bd1c6c9fb78

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe Stratify::CollectorCoordinator do

  describe ".run_all" do
    it "runs all collectors" do
      collector_1 = mock(:run)
      collector_2 = mock(:run)
      
      Stratify::Collector.stubs(:all).returns([collector_1, collector_2])

      Stratify::CollectorCoordinator.run_all
    end
    
    context "when an exception occurs in a collector" do
      it "logs the exception" do
        collector = stub
        collector.stubs(:run).raises("some gnarly error") 
        Stratify::Collector.stubs(:all).returns([collector])
        
        Stratify.logger.expects(:error).with() { |value| value.include? "some gnarly error" }
        Stratify::CollectorCoordinator.run_all
      end
      
      it "runs the remaining collectors" do
        silence_stratify_logging # Silence the logger so as not to clutter the test output

        troublesome_collector = stub
        troublesome_collector.stubs(:run).raises("some gnarly error") 
        
        other_collector = mock
        other_collector.expects(:run).returns(nil)

        Stratify::Collector.stubs(:all).returns([troublesome_collector, other_collector])

        Stratify::CollectorCoordinator.run_all
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stratify-base-0.1.3 spec/stratify/collector_coordinator_spec.rb
stratify-base-0.1.2 spec/stratify/collector_coordinator_spec.rb
stratify-base-0.1.0 spec/stratify/collector_coordinator_spec.rb