Class: Vito::Tests::VagrantTestBox

Inherits:
Object
  • Object
show all
Defined in:
lib/vito/tests/vagrant_test_box.rb

Constant Summary collapse

BOXES_PATH =
"spec/vagrant_boxes/"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ VagrantTestBox

Returns a new instance of VagrantTestBox.



8
9
10
# File 'lib/vito/tests/vagrant_test_box.rb', line 8

def initialize(name)
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/vito/tests/vagrant_test_box.rb', line 6

def name
  @name
end

Class Method Details

.boxes(*boxes) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vito/tests/vagrant_test_box.rb', line 25

def self.boxes(*boxes)
  vagrant_boxes = []
  if boxes.size > 0
    vagrant_boxes = boxes
  else
    Dir["#{BOXES_PATH}*"].each do |box|
      vagrant_boxes << File.basename(box) if File.directory?(box)
    end
  end
  vagrant_boxes.map { |box| new(box) }
end

Instance Method Details

#initial_snapshot_nameObject



21
22
23
# File 'lib/vito/tests/vagrant_test_box.rb', line 21

def initial_snapshot_name
  "#{name}_initial_box"
end

#pathObject



17
18
19
# File 'lib/vito/tests/vagrant_test_box.rb', line 17

def path
  "#{BOXES_PATH}#{name}"
end

#ssh_portObject



12
13
14
15
# File 'lib/vito/tests/vagrant_test_box.rb', line 12

def ssh_port
  grep_result = `grep "network :forwarded_port, guest: 22, host" #{vagrantfile_path}`
  grep_result.match(/host: ([0-9]{4})/)[1]
end