Skip to content
This repository was archived by the owner on Nov 2, 2019. It is now read-only.

Adding version sub-command #10

Merged
merged 1 commit into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/vagrant_spec/command/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# encoding: UTF-8

require 'vagrant_spec/version'

module VagrantSpec
module Command
# Provide CLI interface to retrieving version information
class Version < Vagrant.plugin(2, :command)
def intiialize(argv, env)
@env = env
@argv = argv
end

def execute
return unless parse_opts
@env.ui.info("vagrant_spec: #{VagrantSpec::VERSION}")
end

def parse_opts
opts = OptionParser.new do |o|
o.banner = "\nVersion: Output the version of the plugin"
o.separator ''
o.separator 'Usage: vagrant spec version'
o.separator ''
end
parse_options(opts)
end
end
end
end
6 changes: 4 additions & 2 deletions scripts/poor_mans_smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ set -e

export ANSIBLE_REMOTE_USER=vagrant

bundle exec vagrant spec version
bundle exec vagrant spec version -h
bundle exec vagrant spec
bundle exec vagrant spec -h
bundle exec vagrant spec init -h
bundle exec vagrant spec test -h
bundle exec vagrant spec no_command -h
rm -f serverspec/spec_helper.rb
rm -f .vagrantspec_machine_data
rm -f "serverspec/spec_helper.rb"
rm -f ".vagrantspec_machine_data"
bundle exec vagrant up
bundle exec vagrant spec init
ansible-playbook site.yml -i vagrantspec_inventory
Expand Down
25 changes: 25 additions & 0 deletions spec/unit/vagrant_spec_test/command_spec/version_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# encoding: UTF-8

require 'spec_helper'
require 'vagrant_spec/command/version'

describe VagrantSpec::Command::Version do
include_context 'unit'
include_examples 'shared_mocks'

subject { VagrantSpec::Command::Version.new([], iso_env) }

context 'when parse_opts returns data' do
it '#execute calls env.ui.info' do
allow(subject).to receive(:parse_opts) { 'not_nil' }
expect(mock_ui).to receive(:info)
subject.execute
end
end

it '#parse_opts calls parse_options' do
allow(subject).to receive(:parse_options)
expect(subject).to receive(:parse_options)
subject.parse_opts
end
end