Sha256: c13250be3df53a40864ade5a3b09e3957055a64a6edfa8e90be4668b34f3ad5a

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Orc::Result do
  describe '.success' do
    subject { Orc::Result.success(object) }

    let(:object) { :object }

    it 'signals success' do
      expect(subject.success?).to be(true)
    end

    it 'returns :success status' do
      expect(subject.status).to be(:success)
    end

    it 'exposes the associated object' do
      expect(subject.object).to be(object)
    end
  end

  describe '.failure' do
    shared_context 'a failure result' do
      let(:status) { :confused }
      let(:object) { :context }

      it 'signals failure' do
        expect(subject.success?).to be(false)
      end

      it 'exposes the associated #object' do
        expect(subject.object).to be(object)
      end
    end

    context 'when no status is given' do
      subject { Orc::Result.failure(object) }

      include_context 'a failure result'

      it 'exposes a :failure status' do
        expect(subject.status).to be(:failure)
      end
    end

    context 'when status is given' do
      subject { Orc::Result.failure(object, status) }

      include_context 'a failure result'

      it 'exposes the given #status' do
        expect(subject.status).to be(status)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
orc-0.0.3 spec/unit/orc/result_spec.rb
orc-0.0.2 spec/unit/orc/result_spec.rb