Sha256: 362b1c4b36394a9326946546f83832587bce1804e1b94b4f3f88256c450acb63

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

require 'cap-util'

module CapUtil

  # This defines a base utiltiy for building bundler commands to run.

  class BundlerCmd
    include CapUtil

    attr_reader :cmd

    def initialize(cap, cmd, opts = nil)
      opts ||= {}
      @cap = cap

      opts[:root] ||= :current_path
      opts[:env]  ||= ""

      cmd_root = @cap.send(opts[:root])

      @cmd = "cd #{cmd_root} && #{opts[:env]} bundle exec #{cmd}"
    end

    def run; super(@cmd); end

    module TestHelpers

      def assert_bundler_cmd(util, *args)
        with_backtrace(caller) do
          assert_kind_of BundlerCmd, util

          exp = BundlerCmd.new(*args)
          assert_equal exp.cmd, util.cmd
        end
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cap-util-1.5.2 lib/cap-util/bundler_cmd.rb
cap-util-1.5.1 lib/cap-util/bundler_cmd.rb