Class: Rspec::Bash::StubFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/bash/wrapper/stub_function.rb

Instance Method Summary collapse

Constructor Details

#initialize(port, stub_script_class) ⇒ StubFunction

Returns a new instance of StubFunction.



4
5
6
7
# File 'lib/rspec/bash/wrapper/stub_function.rb', line 4

def initialize(port, stub_script_class)
  @port = port
  @stub_script_class = stub_script_class
end

Instance Method Details

#body(name) ⇒ Object



17
18
19
# File 'lib/rspec/bash/wrapper/stub_function.rb', line 17

def body(name)
  "#{stub_path} #{name} #{@port} \"${@}\""
end


13
14
15
# File 'lib/rspec/bash/wrapper/stub_function.rb', line 13

def footer(name)
  "}\ncommand readonly -f #{name} &> /dev/null"
end

#header(name) ⇒ Object



9
10
11
# File 'lib/rspec/bash/wrapper/stub_function.rb', line 9

def header(name)
  "function #{name} {"
end

#script(name) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rspec/bash/wrapper/stub_function.rb', line 21

def script(name)
  <<-multiline_string
  #{header(name)}
  #{body(name)}
  #{footer(name)}
  multiline_string
end