Sha256: 25dab5fa13d37c0fb384c0795af81b1c8b85fe867e4f62b5f0cf0e8361a85e11

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Raktr::Tasks::Persistent 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

        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/persistent_spec.rb
raktr-0.0.2 spec/raktr/tasks/persistent_spec.rb
raktr-0.0.1 spec/raktr/tasks/persistent_spec.rb