Sha256: 695a04f19f8464e2b05e3ccab65d60e02c98627393673a81b6ed6cff7020057d

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 Bytes

Contents

require 'rspec'
require 'linepipe'
require 'stringio'

module Linepipe
  describe Expectation, '#successful?' do
    let(:io) { StringIO.new }
    let(:log) { double('Log') }

    before do
      log.stub(:call)
    end

    describe 'when it fails' do
      let(:expectation) do
        Expectation.new('Failure message', log) { false }
      end

      it 'prints the message to the output' do
        log.should_receive(:call) do |topic, msg|
          expect(topic).to match(/expectation/i)
          expect(msg).to match(/Failure message/)
        end
        expectation.successful?(%w(some data))
      end

      it 'returns false' do
        expect(expectation.successful?(%w(some data))).to be_false
      end
    end

    describe 'when it passes' do
      let(:expectation) do
        Expectation.new('Failure message', io) { true }
      end

      it 'returns true' do
        expect(expectation.successful?(%w(some data))).to be_true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linepipe-0.2.0 spec/pipeline/expectation_spec.rb
linepipe-0.1.2 spec/pipeline/expectation_spec.rb