Sha256: b5d3614543c4942250a7e5995616e970b929dbbea69ace30eeb8e4e0635b968c

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'mattock/remote-command-task'
require 'mattock/bundle-command-task'
require 'mattock/testing/rake-example-group'
require 'mattock/testing/mock-command-line'

describe Mattock::RemoteCommandTask do
  include Mattock::RakeExampleGroup
  include Mattock::CommandLineExampleGroup

  let! :remote_task do
    namespace :test do
      Mattock::RemoteCommandTask.new do |t|
        t.remote_server.address = "nowhere.com"
        t.command = Mattock::PrereqChain.new do |prereq|
          prereq.add Mattock::CommandLine.new("cd", "a_dir")
          prereq.add Mattock::PipelineChain.new do |pipe|
            pipe.add Mattock::CommandLine.new("ls")
            pipe.add Mattock::CommandLine.new("grep") do |cmd|
              cmd.options << "*.rb"
              cmd.redirect_stderr("/dev/null")
              cmd.redirect_stdout("/tmp/rubyfiles.txt")
            end
          end
        end
        t.verify_command = Mattock::CommandLine.new("should_do")
      end
    end
  end

  describe "when verification indicates command should proceed" do
    it "should run both commands" do
      expect_command(/should_do/, 1)
      expect_command(/^ssh.*cd.*ls.*grep.*rubyfiles.txt/, 0)

      rake["test:run"].invoke
    end
  end
end

describe Mattock::BundleCommandTask do
  include Mattock::RakeExampleGroup
  include Mattock::CommandLineExampleGroup

  let! :bundle_task do
    Mattock::BundleCommandTask.new(:bundle_test) do |t|
      t.command = cmd("bundle", "install", "--standalone")
    end
  end

  it "should run command" do
    expect_command(/bundle install/, 0)
    rake["bundle_test"].invoke
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mattock-0.3.4 spec/command-task.rb
mattock-0.3.3 spec/command-task.rb
mattock-0.3.2 spec/command-task.rb