Sha256: c88cf7b653bbde6e6972660f31aee2cb9ec1dbe307967f3924c8b1ccd5200783

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

module Maid
  module Rake
    describe Task do
      before(:all) { ::Rake::TaskManager.record_task_metadata = true }

      subject(:define_task) { described_class.new(*args, &instructions) }
      let(:instructions)    { proc {} }

      describe '#initialize' do
        before { ::Rake::Task.clear }

        describe 'task body' do
          let(:args) { :foobar }

          it 'sends given instructions to SingleRule' do
            expect(SingleRule)
              .to receive(:perform)
              .with('foobar', instructions)
            define_task && ::Rake::Task[:foobar].execute
          end
        end

        describe 'task description' do
          context 'given just the task name as argument' do
            let(:args) { [:foobar] }

            it 'defines a rake task with default description' do
              desc = described_class.const_get 'DEFAULT_DESCRIPTION'

              define_task
              expect(::Rake::Task[:foobar].comment).to eq(desc)
            end
          end

          context 'given a description argument' do
            let(:args) { [:foobar, { description: 'Custom description' }] }

            it 'defines a rake task with the description provided' do
              define_task
              expect(::Rake::Task[:foobar].comment).to eq('Custom description')
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
maid-0.10.0 spec/lib/maid/rake/task_spec.rb
maid-0.10.0.pre.alpha.3 spec/lib/maid/rake/task_spec.rb
maid-0.10.0.pre.alpha.2 spec/lib/maid/rake/task_spec.rb