Sha256: cff50cf5719cf4ffe9f757468ac56353ed09121059bf1ea5c6db7338bd6e12b6

Contents?: true

Size: 927 Bytes

Versions: 10

Compression:

Stored size: 927 Bytes

Contents

require 'fileutils'

module PkgForge
  ##
  # Add test methods to Forge
  class Forge
    attr_writer :test_block

    Contract None => Proc
    def test_block
      @test_block ||= proc { raise 'No test block provided' }
    end

    Contract None => nil
    def test!
      tester = PkgForge::DSL::Test.new(self)
      tester.instance_eval(&test_block)
    end
  end

  module DSL
    ##
    # Add test methods to Forge DSL
    class Forge
      Contract Func[None => nil] => nil
      def test(&block)
        @forge.test_block = block
        nil
      end
    end

    ##
    # Add test methods to Test DSL
    class Test
      Contract Or[String, Array], Or[HashOf[String => String], {}, nil] => nil
      def run(cmd, env = {})
        cmd.unshift('/usr/bin/env') if cmd.is_a? Array
        cmd << ';' if cmd.is_a? String
        env['PATH'] ||= './usr/bin'
        @forge.test_run(cmd, env)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pkgforge-0.4.8 lib/pkgforge/components/test.rb
pkgforge-0.4.7 lib/pkgforge/components/test.rb
pkgforge-0.4.6 lib/pkgforge/components/test.rb
pkgforge-0.4.5 lib/pkgforge/components/test.rb
pkgforge-0.4.4 lib/pkgforge/components/test.rb
pkgforge-0.4.3 lib/pkgforge/components/test.rb
pkgforge-0.4.2 lib/pkgforge/components/test.rb
pkgforge-0.4.1 lib/pkgforge/components/test.rb
pkgforge-0.4.0 lib/pkgforge/components/test.rb
pkgforge-0.3.0 lib/pkgforge/components/test.rb