Sha256: 3c88366599bc3d870d5cec46565015a782a2f636f79f7e81ef2eb0046760275d

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Taskinator::Api, :redis => true do

  describe Taskinator::Api::Processes do

    it { expect(subject).to be_a(::Enumerable) }

    describe "#each" do
      it "does not enumerate when there aren't any processes" do
        block = SpecSupport::Block.new
        expect(block).to_not receive(:call)
        subject.each(&block)
      end

      it "it enumerates processes" do
        allow_any_instance_of(Process).to receive(:fetch) {}

        Taskinator.redis do |conn|
          conn.multi do
            3.times {|i| conn.sadd("taskinator:#{Taskinator::Persistence.list_key}", i) }
          end
        end

        block = SpecSupport::Block.new
        expect(block).to receive(:call).exactly(3).times

        subject.each(&block)
      end
    end

    describe "#size" do
      it { expect(subject.size).to eq(0) }

      it "yields the number of processes" do
        Taskinator.redis do |conn|
          conn.multi do
            3.times {|i| conn.sadd("taskinator:#{Taskinator::Persistence.list_key}", i) }
          end
        end

        expect(subject.size).to eq(3)
      end
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
taskinator-0.3.3 spec/taskinator/api_spec.rb
taskinator-0.3.2 spec/taskinator/api_spec.rb
taskinator-0.3.1 spec/taskinator/api_spec.rb
taskinator-0.3.0 spec/taskinator/api_spec.rb
taskinator-0.2.0 spec/taskinator/api_spec.rb
taskinator-0.0.18 spec/taskinator/api_spec.rb
taskinator-0.0.17 spec/taskinator/api_spec.rb
taskinator-0.0.16 spec/taskinator/api_spec.rb