Sha256: b6b0ed5dbfc7bb21687a3eb7f6d4961e07ea8ddde0235d59284616140e3c94ec

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Raktr::Tasks::OneOff do
    it_should_behave_like 'Raktr::Tasks::Base'

    let(:list) { Raktr::Tasks.new }
    subject { described_class.new{} }

    describe '#initialize' do
        context 'when no task have been given' do
            it "raises #{ArgumentError}" do
                expect { described_class.new }.to raise_error ArgumentError
            end
        end
    end

    describe '#call' do
        it 'calls the given task' do
            callable = proc {}
            callable.should receive(:call)

            task = described_class.new(&callable)
            list << task

            task.call
        end

        it 'passes the task to it' do
            callable = proc {}
            task = described_class.new(&callable)

            callable.should receive(:call).with(task)

            list << task

            task.call
        end

        it 'calls #done' do
            callable = proc {}
            task = described_class.new(&callable)

            callable.should receive(:call).with(task)

            list << task

            task.should receive(:done)
            task.call
        end

        context 'when arguments have been provided' do
            it 'passes them to the task' do
                got = nil
                callable = proc do |_, arg|
                    got = arg
                end

                task = described_class.new(&callable)
                list << task

                task.call :stuff
                got.should == :stuff
            end
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
raktr-0.0.3 spec/raktr/tasks/one_off_spec.rb
raktr-0.0.2 spec/raktr/tasks/one_off_spec.rb
raktr-0.0.1 spec/raktr/tasks/one_off_spec.rb