Sha256: 8d4a43f54b0ee69200875bf75a56d431cae7e8ea0a7818a617f6ad49ccda6a2c

Contents?: true

Size: 1.73 KB

Versions: 19

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'
require 'tmpdir'

module RevealCK
  module Builders
    class RakeAwareTestingClass
      include RakeAware
      attr_reader :application
      def initialize
        @application = Rake::Application.new
      end
    end

    describe RakeAware do
      describe 'when included into a class with a rake application' do
        let :example do
          RakeAwareTestingClass.new
        end

        describe '#task' do
          it 'provides a shortcut for defining a task' do
            signal = false
            example.task('example_task') do
              signal = true
            end
            example.application['example_task'].invoke
            expect(signal).to be true
          end
        end

        describe '#copy_file' do
          it 'provides a shortcut for copying files' do
            Dir.mktmpdir do |dir|
              Dir.chdir(dir) do
                File.open('source', 'w') { |file| file.write('source') }
                example.copy_file('source', 'destination')
                example.application['destination'].invoke
                expect(File.exist?('destination')).to be true
                content = File.open('destination', 'r').read
                expect(content).to eq 'source'
              end
            end
          end
        end

        describe '#create_directory' do
          it 'provides a shortcut for creating a directory' do
            Dir.mktmpdir do |dir|
              Dir.chdir(dir) do
                example.create_directory('example_directory')
                example.application['example_directory'].invoke
                expect(File.directory?('example_directory')).to be true
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
reveal-ck-4.0.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.9.2 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.9.1 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.9.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.8.1 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.8.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.7.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.6.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.5.1 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.5.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.4.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.3.1 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.3.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.2.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.1.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.0.1 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-3.0.0 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-0.6.2 spec/lib/reveal-ck/builders/rake_aware_spec.rb
reveal-ck-0.6.1 spec/lib/reveal-ck/builders/rake_aware_spec.rb