Sha256: 1165ae18b1d5a8525ce4ddb39186f1220efd54e658042354e50b54dbc82dcd3e

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Yardstick::MeasurementSet, '#puts' do
  let(:set)      { described_class.new([failed, successful]) }
  let(:document) { DocumentMock.new                          }

  let(:failed) do
    Class.new do
      def ok?
        false
      end

      def puts(io)
        io.puts('measurement info')
      end
    end.new
  end

  let(:successful) do
    Class.new do
      def ok?
        true
      end

      def puts(io)
        io.puts('measurement info')
      end
    end.new
  end

  describe 'with no arguments' do
    before do
      capture_stdout { set.puts }
    end

    it 'should output the summary' do
      expect(@output).to eql([
        'measurement info',
        'measurement info',
        "\nYARD-Coverage: 50.0%  Success: 1  Failed: 1  Total: 2\n"
      ].join("\n"))
    end
  end

  describe 'with an object implementing #puts' do
    before do
      io = StringIO.new
      set.puts(io)
      io.rewind
      @output = io.read
    end

    it 'should output the summary' do
      expect(@output).to eql([
        'measurement info',
        'measurement info',
        "\nYARD-Coverage: 50.0%  Success: 1  Failed: 1  Total: 2\n",
      ].join("\n"))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yardstick-0.9.9 spec/unit/yardstick/measurement_set/puts_spec.rb
yardstick-0.9.8 spec/unit/yardstick/measurement_set/puts_spec.rb
yardstick-0.9.7 spec/unit/yardstick/measurement_set/puts_spec.rb