2011-11-05 21:59:17 +00:00
|
|
|
module Acceptance
|
|
|
|
# This class helps with matching against output so that every
|
|
|
|
# test isn't inherently tied to the output format of Vagrant.
|
|
|
|
class Output
|
2011-11-22 06:09:51 +00:00
|
|
|
DEFAULT_VM = "default"
|
|
|
|
|
2011-11-05 21:59:17 +00:00
|
|
|
def initialize(text)
|
|
|
|
@text = text
|
|
|
|
end
|
|
|
|
|
2011-11-05 22:01:00 +00:00
|
|
|
# Checks that an error message was outputted about the box
|
|
|
|
# being added being invalid.
|
2011-11-05 21:59:17 +00:00
|
|
|
def box_invalid
|
|
|
|
@text =~ /^The box file you're attempting to add is invalid./
|
|
|
|
end
|
|
|
|
|
2011-11-05 22:01:00 +00:00
|
|
|
# Checks that an error message was outputted about the path
|
|
|
|
# not existing to the box.
|
2011-11-05 21:59:17 +00:00
|
|
|
def box_path_doesnt_exist
|
|
|
|
@text =~ /^The specified path to a file doesn't exist.$/
|
|
|
|
end
|
|
|
|
|
2011-11-05 22:01:00 +00:00
|
|
|
# Tests that the box with given name is installed.
|
2011-11-05 21:59:17 +00:00
|
|
|
def box_installed(name)
|
2011-11-05 22:01:00 +00:00
|
|
|
@text =~ /^#{name}$/
|
2011-11-05 21:59:17 +00:00
|
|
|
end
|
|
|
|
|
2011-11-05 22:01:00 +00:00
|
|
|
# Tests that the output says there are no installed boxes.
|
2011-11-05 21:59:17 +00:00
|
|
|
def no_boxes
|
|
|
|
@text =~ /There are no installed boxes!/
|
|
|
|
end
|
|
|
|
|
2011-11-07 02:23:06 +00:00
|
|
|
# Tests that the output says there is no Vagrantfile, and as such
|
|
|
|
# can't do whatever we requested Vagrant to do.
|
|
|
|
def no_vagrantfile
|
2011-12-18 21:26:15 +00:00
|
|
|
@text =~ /^A Vagrant environment is required/
|
2011-11-07 02:23:06 +00:00
|
|
|
end
|
|
|
|
|
2011-11-05 22:01:00 +00:00
|
|
|
# Tests that the output contains a specific Vagrant version.
|
2011-11-09 07:03:15 +00:00
|
|
|
def version(version)
|
2011-11-05 21:59:17 +00:00
|
|
|
@text =~ /^Vagrant version #{version}$/
|
|
|
|
end
|
2011-11-06 21:30:49 +00:00
|
|
|
|
|
|
|
# This checks that the VM with the given `vm_name` has the
|
|
|
|
# status of `status`.
|
|
|
|
def status(vm_name, status)
|
|
|
|
@text =~ /^#{vm_name}\s+#{status}$/
|
|
|
|
end
|
2011-11-07 06:21:02 +00:00
|
|
|
|
|
|
|
# This checks that an error message that the VM must be created
|
|
|
|
# is shown.
|
|
|
|
def error_vm_must_be_created
|
|
|
|
@text =~ /^VM must be created/
|
|
|
|
end
|
2011-11-20 21:37:01 +00:00
|
|
|
|
2011-11-20 21:39:54 +00:00
|
|
|
# This checks that the warning that the VM is not created is emitted.
|
|
|
|
def vm_not_created_warning
|
|
|
|
@text =~ /VM not created. Moving on...$/
|
|
|
|
end
|
|
|
|
|
2011-11-20 21:37:01 +00:00
|
|
|
# This checks that the VM is destroyed.
|
|
|
|
def vm_destroyed
|
|
|
|
@text =~ /Destroying VM and associated drives...$/
|
|
|
|
end
|
2011-11-22 05:55:03 +00:00
|
|
|
|
|
|
|
# This checks that the "up" output properly contains text showing that
|
|
|
|
# it is downloading the box during the up process.
|
2011-11-22 06:09:51 +00:00
|
|
|
def up_fetching_box(name, vm=DEFAULT_VM)
|
2011-11-22 06:39:12 +00:00
|
|
|
@text =~ /^\[#{vm}\] Box #{name} was not found. Fetching box from specified URL...$/
|
2011-11-22 05:55:03 +00:00
|
|
|
end
|
2011-11-23 03:34:25 +00:00
|
|
|
|
|
|
|
# Check that the output shows that the VM was shut down gracefully
|
|
|
|
def vm_halt_graceful
|
|
|
|
@text =~ /Attempting graceful shutdown of/
|
|
|
|
end
|
|
|
|
|
|
|
|
# Output shows a forceful VM shutdown.
|
|
|
|
def vm_halt_force
|
|
|
|
@text =~ /Forcing shutdown of VM...$/
|
|
|
|
end
|
2011-11-24 23:15:45 +00:00
|
|
|
|
|
|
|
# Output shows the VM is in the process of suspending
|
|
|
|
def vm_suspending
|
|
|
|
@text =~ /Saving VM state and suspending execution...$/
|
|
|
|
end
|
2011-11-05 21:59:17 +00:00
|
|
|
end
|
|
|
|
end
|