Sha256: 0a8584656982ae40717ffac36c2b36cc321db737db9afd8e085f95d437eb8faa

Contents?: true

Size: 837 Bytes

Versions: 3

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper'

module RevealCK
  module Builders

    describe Builder, 'when subclassed' do

      it 'requires that subclasses implement #register_tasks' do
        class BadBuilder < Builder; end
        bad_builder = BadBuilder.new
        expect { bad_builder.register_tasks }.to raise_error
      end

      it 'invokes each registered task when it receives #build' do

        class TestBuilder < Builder

          attr_reader :value

          def initialize
            @value = 0
          end

          def register_tasks
            @tasks = []
            @value = 0
            add_task 'Set Value to 1' do
              @value = 1
            end
          end
        end

        test_builder = TestBuilder.new
        test_builder.build!
        expect(test_builder.value).to eq 1
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reveal-ck-0.2.0 spec/lib/reveal-ck/builders/builder_spec.rb
reveal-ck-0.1.8 spec/lib/reveal-ck/builders/builder_spec.rb
reveal-ck-0.1.7 spec/lib/reveal-ck/builders/builder_spec.rb