Sha256: 4d81f05540ad27d73637d2530dda1b7d6a9680de10a602c5cccab9ef60d3c44d

Contents?: true

Size: 1.85 KB

Versions: 15

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

module Berkshelf
  describe TXResultSet do
    subject { TXResultSet.new }

    let(:failed_result) do
      result = double("result")
      result.stub(:failed?) { true }
      result.stub(:success?) { false }
      result
    end

    let(:successful_result) do
      result = double("result")
      result.stub(:failed?) { false }
      result.stub(:success?) { true }
      result
    end

    describe "#add_result" do
      it "adds a result to the results attribute" do
        subject.add_result(successful_result)

        subject.results.should have(1).result
      end

      it "raises an ArgumentError if an invalid result is given" do
        lambda {
          subject.add_result("string_isnt_a_result")
        }.should raise_error(ArgumentError)
      end
    end

    describe "#failed" do
      it "returns the failed results if there were failed results" do
        subject.add_result(failed_result)

        subject.failed.should have(1).result
      end

      it "returns no results if there were no failures" do
        subject.add_result(successful_result)

        subject.failed.should have(0).results
      end
    end

    describe "#success" do
      it "returns the successful results if there were successful results" do
        subject.add_result(successful_result)

        subject.success.should have(1).result
      end

      it "returns no results if there were no successes" do
        subject.add_result(failed_result)

        subject.success.should have(0).results
      end
    end

    describe "#has_errors?" do
      it "returns true if any result was a failure" do
        subject.add_result(failed_result)

        subject.failed.should be_true
      end

      it "returns false if every result was a success" do
        subject.add_result(successful_result)

        subject.failed.should be_true
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
berkshelf-0.4.0.rc4 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.4.0.rc3 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.4.0.rc2 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.4.0.rc1 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.3.7 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.3.3 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.3.2 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.3.1 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.3.0 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.2.0 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.1.5 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.1.4 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.1.3 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.1.2 spec/unit/berkshelf/tx_result_set_spec.rb
berkshelf-0.1.1 spec/unit/berkshelf/tx_result_set_spec.rb