diff --git a/.config/cucumber.yml b/.config/cucumber.yml new file mode 100644 index 0000000..52d116b --- /dev/null +++ b/.config/cucumber.yml @@ -0,0 +1,7 @@ +# config/cucumber.yml +##YAML Template +--- +default: --profile html + +pretty: --format pretty -b +html: --format progress --format html --out=build/features_report.html -b diff --git a/.gitignore b/.gitignore index 7511f9b..dea5e76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Build artifacts pkg +build # Ruby / Bundler Gemfile.lock diff --git a/README.md b/README.md index a7ab8f0..f70f31b 100644 --- a/README.md +++ b/README.md @@ -195,16 +195,24 @@ And finally bring up your Vagrant guest: ## Appendix B: Development -For local development of this plugin here is an example of how to build -and install this plugin on your local machine: - -``` -$ rake build -vagrant-sshfs 0.1.0 built to pkg/vagrant-sshfs-0.1.0.gem. -$ mkdir -p /tmp/gems/gems -$ cp pkg/vagrant-sshfs-0.1.0.gem /tmp/gems/gems/ -$ pushd /tmp/gems/ -$ gem generate_index -$ popd -$ vagrant plugin install vagrant-sshfs --plugin-source file:///tmp/gems/ +For local development of this plugin here is an example of how to build, test and install this plugin on your local machine: + +``` +# Install development dependencies +$ gem install bundler && bundle install + +# List available Rake tasks +$ bundle exec rake -T + +# Run Cucumber tests +$ bundle exec rake features + +# Build the gem (gets generated in the 'pkg' directory +$ bundle exec rake build + +# Run Vagrant in the context of the plugin +$ bundle exec rake vagrant + +# Install built gem into global Vagrant installation (run outside of git checkout!) +$ vagrant plugin install ``` diff --git a/Rakefile b/Rakefile index 809eb56..002bee0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,23 @@ -require "bundler/gem_tasks" +require 'bundler/gem_tasks' +require 'rake/clean' +require 'cucumber/rake/task' +require 'launchy' + +CLOBBER.include('pkg') +CLEAN.include('build') + +task :init do + FileUtils.mkdir_p 'build' +end + +# Cucumber acceptance test task +Cucumber::Rake::Task.new(:features) +task :features => :init + +namespace :features do + desc 'Opens the HTML Cucumber test report' + task :open_report do + Launchy.open('./build/features_report.html') + end +end diff --git a/features/step_definitions/user_home_dir_mount_steps.rb b/features/step_definitions/user_home_dir_mount_steps.rb new file mode 100644 index 0000000..ebd92e9 --- /dev/null +++ b/features/step_definitions/user_home_dir_mount_steps.rb @@ -0,0 +1,4 @@ +And(/^user's home directory should be mounted$/) do + run("vagrant ssh -c \"ls #{ENV['HOME']}\"") + expect(last_command_started).to have_exit_status(0) +end diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..b626eeb --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,14 @@ +require 'aruba/cucumber' +require 'komenda' + +Aruba.configure do |config| + config.exit_timeout = 300 + config.activate_announcer_on_command_failure = [:stdout, :stderr] + config.working_directory = 'build/aruba' +end + +After do |_scenario| + if File.exist?(File.join(aruba.config.working_directory, 'Vagrantfile')) + Komenda.run('bundle exec vagrant destroy -f', cwd: aruba.config.working_directory, fail_on_fail: true) + end +end diff --git a/features/user_home_dir_mount.feature b/features/user_home_dir_mount.feature new file mode 100644 index 0000000..38795b8 --- /dev/null +++ b/features/user_home_dir_mount.feature @@ -0,0 +1,28 @@ +Feature: Mount of user home directory + + Scenario Outline: Mounting the user's home directory + Given a file named "Vagrantfile" with: + """ + Vagrant.configure('2') do |config| + config.vm.box = '' + config.vm.synced_folder '.', '/vagrant', disabled: true + + if Vagrant::Util::Platform.windows? + target_path = ENV['USERPROFILE'].gsub(/\\/,'/').gsub(/[[:alpha:]]{1}:/){|s|'/' + s.downcase.sub(':', '')} + config.vm.synced_folder ENV['USERPROFILE'], target_path, type: 'sshfs', sshfs_opts_append: '-o umask=000 -o uid=1000 -o gid=1000' + else + config.vm.synced_folder ENV['HOME'], ENV['HOME'], type: 'sshfs', sshfs_opts_append: '-o umask=000 -o uid=1000 -o gid=1000' + end + end + """ + When I successfully run `bundle exec vagrant up --provider ` + Then stdout from "bundle exec vagrant up --provider " should contain "Installing SSHFS client..." + And stdout from "bundle exec vagrant up --provider " should contain "Mounting SSHFS shared folder..." + And stdout from "bundle exec vagrant up --provider " should contain "Folder Successfully Mounted!" + And user's home directory should be mounted + + Examples: + | box | provider | + | centos/7 | virtualbox | + + \ No newline at end of file diff --git a/vagrant-sshfs.gemspec b/vagrant-sshfs.gemspec index ce96c83..ec6c803 100644 --- a/vagrant-sshfs.gemspec +++ b/vagrant-sshfs.gemspec @@ -23,6 +23,10 @@ Gem::Specification.new do |spec| spec.add_dependency 'win32-process' - spec.add_development_dependency "bundler", "~> 1.7" - spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency 'bundler', '~> 1.7' + spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'cucumber', '~> 2.1' + spec.add_development_dependency 'aruba', '~> 0.13' + spec.add_development_dependency 'komenda', '~> 0.1.6' + spec.add_development_dependency 'launchy' end