Sha256: b28f9d9c08a0521a7efe52853f35b06be2d220b2eb288e4dcadcb0766f9dd30f

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Yardstick::Measurement, '#puts' do
  let(:document) { DocumentMock.new }

  describe 'with no arguments' do
    subject { @output }

    before do
      capture_stdout { described_class.new(rule).puts }
    end

    describe 'when the measurement is successful' do
      let(:rule) { ValidRule.new(document) }

      it { should == '' }
    end

    describe 'when the measurement is skipped' do
      let(:rule) { NotValidatableRule.new(document) }

      it { should == '' }
    end

    describe 'when the measurement is not successful' do
      let(:rule) { InvalidRule.new(document) }

      it { should == "(stdin):2: Foo#bar: not successful\n" }
    end
  end

  describe 'with an object implementing #puts' do
    subject { io.read }

    let(:io) { StringIO.new }

    before do
      described_class.new(rule).puts(io)
      io.rewind
    end

    describe 'when the measurement is successful' do
      let(:rule) { ValidRule.new(document) }

      it { should == '' }
    end

    describe 'when the measurement is skipped' do
      let(:rule) { NotValidatableRule.new(document) }

      it { should == '' }
    end

    describe 'when the measurement is not successful' do
      let(:rule) { InvalidRule.new(document) }

      it { should == "(stdin):2: Foo#bar: not successful\n" }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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