Sha256: 7fc0480c3da1912951b849b663a2881fa119551d2dc999406ac7d5ba8104015b

Contents?: true

Size: 1.63 KB

Versions: 7

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe ROM::Commands::Result do
  describe '#value' do
    subject(:result) { ROM::Commands::Result::Success }

    it 'bubble up nested values' do
      data = double(to_ary: ['foo'])
      r = result.new(result.new(result.new(data)))

      expect(r.value).to eq(data)
    end
  end

  describe '#success?' do
    context 'not launched command' do
      subject(:command) { ROM::Commands::Result }

      it 'returns false' do
        expect(command.new.success?).to eq(false)
      end
    end

    context 'successful command' do
      subject(:result) { ROM::Commands::Result::Success }

      it 'returns true' do
        data = double(to_ary: ['foo'])
        expect(result.new(data).success?).to eq(true)
      end
    end

    context 'failed command' do
      subject(:result) { ROM::Commands::Result::Failure }

      it 'returns false' do
        error = double(:error)
        expect(result.new(error).success?).to eq(false)
      end
    end
  end

  describe '#failure?' do
    context 'not launched command' do
      subject(:command) { ROM::Commands::Result }

      it 'returns false' do
        expect(command.new.success?).to eq(false)
      end
    end

    context 'successful command' do
      subject(:result) { ROM::Commands::Result::Success }

      it 'returns false' do
        data = double(to_ary: ['foo'])
        expect(result.new(data).failure?).to eq(false)
      end
    end

    context 'failed command' do
      subject(:result) { ROM::Commands::Result::Failure }

      it 'returns true' do
        error = double(:error)
        expect(result.new(error).failure?).to eq(true)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-2.0.2 spec/unit/rom/commands/result_spec.rb
rom-2.0.1 spec/unit/rom/commands/result_spec.rb
rom-2.0.0 spec/unit/rom/commands/result_spec.rb
rom-1.0.0 spec/unit/rom/commands/result_spec.rb
rom-1.0.0.rc1 spec/unit/rom/commands/result_spec.rb
rom-1.0.0.beta2 spec/unit/rom/commands/result_spec.rb
rom-1.0.0.beta1 spec/unit/rom/commands/result_spec.rb