Module: Capistrano::Spec::ConfigurationExtension

Defined in:
lib/capistrano/spec.rb

Instance Method Summary collapse

Instance Method Details

#download(from, to, options = {}, &block) ⇒ Object


37
38
39
# File 'lib/capistrano/spec.rb', line 37

def download(from, to, options={}, &block)
  downloads[to] = {:from => from, :options => options, :block => block}
end

#downloadsObject


41
42
43
# File 'lib/capistrano/spec.rb', line 41

def downloads
  @downloads ||= {}
end

#get(remote_path, path, options = {}, &block) ⇒ Object


4
5
6
# File 'lib/capistrano/spec.rb', line 4

def get(remote_path, path, options={}, &block)
  gets[remote_path] = {:path => path, :options => options, :block => block}
end

#getsObject


8
9
10
# File 'lib/capistrano/spec.rb', line 8

def gets
  @gets ||= {}
end

#run(cmd, options = {}, &block) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/capistrano/spec.rb', line 12

def run(cmd, options={}, &block)
  runs[cmd] = {:options => options, :block => block}
  if (stub = stubbed_commands[cmd])
    raise ::Capistrano::CommandError if stub[:fail]
    raise stub[:raise] if stub[:raise]

    data = stub[:data]
    data = stub[:with].call(cmd) if stub[:with].respond_to? :call

    block.call stub[:channel], stub[:stream], data if block_given?
  end
end

#runsObject


25
26
27
# File 'lib/capistrano/spec.rb', line 25

def runs
  @runs ||= {}
end

#stub_command(command, options = {}, &block) ⇒ Object


49
50
51
52
# File 'lib/capistrano/spec.rb', line 49

def stub_command(command, options = {}, &block)
  options[:with] = block if block_given?
  stubbed_commands[command] = { :stream => :out, :data => '' }.merge options
end

#stubbed_commandsObject


45
46
47
# File 'lib/capistrano/spec.rb', line 45

def stubbed_commands
  @stubbed_commands ||= {}
end

#upload(from, to, options = {}, &block) ⇒ Object


29
30
31
# File 'lib/capistrano/spec.rb', line 29

def upload(from, to, options={}, &block)
  uploads[from] = {:to => to, :options => options, :block => block}
end

#uploadsObject


33
34
35
# File 'lib/capistrano/spec.rb', line 33

def uploads
  @uploads ||= {}
end