Project

orc

0.0
No commit activity in last 3 years
No release in over 3 years
Operation result class
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.6.5, ~> 1.6
>= 3.0.0, ~> 3.0

Runtime

>= 0.0.7, ~> 0.0
>= 0.1.5, ~> 0.1
 Project Readme

orc

Gem Version Build Status Dependency Status Code Climate Coverage Status

Usage

Whenever you want to communicate success or failure of an operation, the following might be handy

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

Credits

Contributing

See CONTRIBUTING.md for details.

Copyright

Copyright © 2014 Martin Gamsjaeger (snusnu). See LICENSE for details.