vagrant-cucumber 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -0
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/example/Vagrantfile +3 -4
- data/example/features/step_definitions/process.rb +13 -24
- data/example/features/support/env.rb +1 -1
- data/lib/vagrant-cucumber/commands/cucumber.rb +9 -10
- data/lib/vagrant-cucumber/cucumber/formatter/html.rb +1 -2
- data/lib/vagrant-cucumber/cucumber/formatter/pretty.rb +1 -1
- data/lib/vagrant-cucumber/glue.rb +13 -17
- data/lib/vagrant-cucumber/step_definitions.rb +45 -14
- data/lib/vagrant-cucumber/version.rb +1 -1
- data/vagrant-cucumber.gemspec +4 -3
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3dd0d7308492b17caa19ea3f3f0ebee0b3073a2
|
4
|
+
data.tar.gz: b6f31e27c53386fef198c4b1294b22ffee91a5c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 017ab2efd36c26b684f2837f4f9366ea1c241a444c934cae25059e131872c52325ce191a10944d36b07c9f4e7cc95938367d75819b85beb2bfaf413b17b90a8b
|
7
|
+
data.tar.gz: 0f39cbe18a5836e3efe7a8985fd7a6ff92776d59f9a46f1101d97866a471001baf72b58d6bd71c32d5d4179e7db62a4c6d99c870aba28383a078b09cd8d4fa3a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Style/IndentationWidth:
|
2
|
+
Width: 4
|
3
|
+
|
4
|
+
Metrics/LineLength:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/MethodLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/Documentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/AccessorMethodName:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/ClassVars:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/AbcSize:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Lint/AmbiguousRegexpLiteral:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/FileName:
|
26
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.0.0 (December, 2016)
|
2
|
+
* Upgrade Cucumber to 2.x release. No longer requires native extensions for Gherkin,
|
3
|
+
thus allowing installation on Vagrant 1.9.1
|
4
|
+
* Support for libvirt using Sahara plugin
|
5
|
+
|
1
6
|
## 0.1.1 (26 July, 2016)
|
2
7
|
|
3
8
|
* Retry snapshot operations on lock failure.
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ install this plugin is via the published gem:
|
|
43
43
|
vagrant plugin install vagrant-cucumber
|
44
44
|
```
|
45
45
|
|
46
|
-
`vagrant-cucumber` will install a version of cucumber >=
|
46
|
+
`vagrant-cucumber` will install a version of cucumber >= 2.4.0 under the
|
47
47
|
Ruby environment provided by Vagrant.
|
48
48
|
|
49
49
|
|
data/example/Vagrantfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Vagrant.configure('2') do |config|
|
2
|
-
config.vm.box =
|
2
|
+
config.vm.box = 'ubuntu/precise64'
|
3
3
|
|
4
4
|
config.vm.provider :virtualbox
|
5
5
|
|
6
|
-
config.vm.provider :vmware_fusion do |
|
6
|
+
config.vm.provider :vmware_fusion do |_fusion, override|
|
7
7
|
# Standard Ubuntu image doesn't exist for VMWare
|
8
|
-
override.vm.box =
|
8
|
+
override.vm.box = 'hashicorp/precise64'
|
9
9
|
end
|
10
10
|
|
11
11
|
config.vm.define :vm1 do |vm1|
|
@@ -15,5 +15,4 @@ Vagrant.configure('2') do |config|
|
|
15
15
|
config.vm.define :vm2 do |vm2|
|
16
16
|
vm2.vm.hostname = 'vm2'
|
17
17
|
end
|
18
|
-
|
19
18
|
end
|
@@ -1,16 +1,15 @@
|
|
1
|
-
# Cucumber step definitions are defined like function definitions, and start
|
1
|
+
# Cucumber step definitions are defined like function definitions, and start
|
2
2
|
# with a preposition or adverb (Given, When, Then, And, But).
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# The regular expression defined will be matched against steps in the feature
|
5
5
|
# files when cucumber runs. The matched groups in the regex will be passed
|
6
|
-
# in order as variables to the block. In this case, the three groups are
|
6
|
+
# in order as variables to the block. In this case, the three groups are
|
7
7
|
# assigned to "condition", "process_name" and "vmre"
|
8
8
|
#
|
9
9
|
# More information on step definitions can be found at
|
10
10
|
# https://github.com/cucumber/cucumber/wiki/Step-Definitions
|
11
11
|
|
12
12
|
Then /there should(| not) be a process called "([^"]*)" running(#{VMRE})$/ do |condition, process_name, vmre|
|
13
|
-
|
14
13
|
# First, we work out what virtual machine we're going to be dealing with
|
15
14
|
# in this step. The VMRE variable in the regex above is defined by
|
16
15
|
# vagrant-cucumber to match various English-language ways in which we
|
@@ -28,50 +27,40 @@ Then /there should(| not) be a process called "([^"]*)" running(#{VMRE})$/ do |c
|
|
28
27
|
|
29
28
|
machine = vagrant_glue.identified_vm(vmre)
|
30
29
|
|
31
|
-
|
32
30
|
# Now we use the machine's communication interface (probably ssh, though
|
33
31
|
# this is provider-dependent) to execute a shell command inside the VM.
|
34
32
|
|
35
33
|
machine.communicate.tap do |comm|
|
34
|
+
rv = comm.execute(
|
35
|
+
"pidof #{process_name}",
|
36
|
+
error_check: false, # stop vagrant throwing an exception
|
37
|
+
# if the command returns non-zero
|
36
38
|
|
37
|
-
|
38
|
-
"pidof #{process_name}", {
|
39
|
-
:error_check => false, # stop vagrant throwing an exception
|
40
|
-
} # if the command returns non-zero
|
41
|
-
|
42
|
-
) do |type,data|
|
43
|
-
|
39
|
+
) do |type, data|
|
44
40
|
# Execute takes a block, which is yielded to whenever there's
|
45
41
|
# output on stdout or stderr. We handle any output in this block.
|
46
42
|
#
|
47
43
|
# In this case, we'll put all output onto stdout, but only if
|
48
44
|
# @vagrant_cucumber_debug has been set. This class variable will
|
49
|
-
# be set to true in the Before hook defined in
|
45
|
+
# be set to true in the Before hook defined in
|
50
46
|
# lib/vagrant-cucumber/step_definitions.rb
|
51
47
|
|
52
|
-
if @vagrant_cucumber_debug
|
53
|
-
puts "[:#{type}] #{data.chomp}"
|
54
|
-
end
|
55
|
-
|
48
|
+
puts "[:#{type}] #{data.chomp}" if @vagrant_cucumber_debug
|
56
49
|
end
|
57
50
|
|
58
51
|
# Output the status from the command if we're in debugging mode
|
59
|
-
if @vagrant_cucumber_debug
|
60
|
-
puts "Exit status of pidof command: #{rv}"
|
61
|
-
end
|
52
|
+
puts "Exit status of pidof command: #{rv}" if @vagrant_cucumber_debug
|
62
53
|
|
63
54
|
# Cucumber steps are expected to exit cleanly if they worked ok, and
|
64
55
|
# raise exceptions if they fail. The following logic implements
|
65
56
|
# the conditions in which we want to fail the step.
|
66
57
|
|
67
|
-
if rv != 0
|
58
|
+
if rv != 0 && condition == ''
|
68
59
|
raise "There was no proces called #{process_name} running on #{machine.name}"
|
69
60
|
end
|
70
61
|
|
71
|
-
if rv == 0
|
62
|
+
if rv == 0 && condition == ' not'
|
72
63
|
raise "There was a process called #{process_name} running on #{machine.name}"
|
73
64
|
end
|
74
|
-
|
75
65
|
end
|
76
|
-
|
77
66
|
end
|
@@ -1,17 +1,16 @@
|
|
1
|
-
FORCE_COLOUR_ENV_VARS =
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
FORCE_COLOUR_ENV_VARS = %w(
|
2
|
+
VAGRANT_CUCUMBER_FORCE_COLOR
|
3
|
+
VAGRANT_CUCUMBER_FORCE_COLOUR
|
4
|
+
).freeze
|
5
5
|
|
6
6
|
module VagrantPlugins
|
7
7
|
module Cucumber
|
8
8
|
class CucumberCommand < Vagrant.plugin(2, :command)
|
9
9
|
FORCE_COLOUR_ENV_VARS.each do |k|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
10
|
+
next unless ENV.key?(k)
|
11
|
+
require 'cucumber/term/ansicolor'
|
12
|
+
::Cucumber::Term::ANSIColor.coloring = true
|
13
|
+
break
|
15
14
|
end
|
16
15
|
|
17
16
|
def execute
|
@@ -24,7 +23,7 @@ module VagrantPlugins
|
|
24
23
|
|
25
24
|
VagrantPlugins::Cucumber::Glue::VagrantGlue.set_environment(@env)
|
26
25
|
|
27
|
-
|
26
|
+
_ = ::Cucumber::Cli::Main.execute(@argv)
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'cucumber/formatter/html'
|
2
2
|
|
3
|
-
ANSI_PATTERN = /\e\[
|
3
|
+
ANSI_PATTERN = /\e\[\d+([;\d]+)?m/
|
4
4
|
|
5
5
|
def remove_ansi(string = nil)
|
6
6
|
string.gsub(ANSI_PATTERN, '')
|
@@ -11,7 +11,6 @@ module VagrantPlugins
|
|
11
11
|
module Formatter
|
12
12
|
class Html < ::Cucumber::Formatter::Html
|
13
13
|
def puts(message)
|
14
|
-
# TODO: Strip ansi escape codes
|
15
14
|
@delayed_messages << remove_ansi(message)
|
16
15
|
end
|
17
16
|
end
|
@@ -22,17 +22,15 @@ module VagrantPlugins
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def initialize
|
25
|
-
@vagrant_env = @@vagrant_env
|
25
|
+
(@vagrant_env = @@vagrant_env) || raise("The vagrant_env hasn't been set")
|
26
26
|
@last_machine_mentioned = nil
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.instance
|
30
|
-
|
30
|
+
@@instance ||= VagrantGlue.new
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
@vagrant_env
|
35
|
-
end
|
33
|
+
attr_reader :vagrant_env
|
36
34
|
|
37
35
|
def get_last_vm
|
38
36
|
get_vm(@last_machine_mentioned)
|
@@ -55,9 +53,9 @@ module VagrantPlugins
|
|
55
53
|
end
|
56
54
|
|
57
55
|
unless machine_name
|
58
|
-
raise "The VM '#{vmname}' is configured in the Vagrantfile "
|
59
|
-
|
60
|
-
|
56
|
+
raise "The VM '#{vmname}' is configured in the Vagrantfile "\
|
57
|
+
"but has not been started. Run 'vagrant up #{vmname}' and "\
|
58
|
+
'specify a provider if necessary.'
|
61
59
|
end
|
62
60
|
|
63
61
|
machine_provider ||= vagrant_env.default_provider
|
@@ -74,10 +72,10 @@ module VagrantPlugins
|
|
74
72
|
|
75
73
|
def identified_vm(str)
|
76
74
|
case str
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
when /^( on the last VM|)$/
|
76
|
+
get_last_vm
|
77
|
+
when /^ on the VM(?: called|) "([^"]+)"$/
|
78
|
+
get_vm(Regexp.last_match(1))
|
81
79
|
end
|
82
80
|
end
|
83
81
|
|
@@ -87,17 +85,15 @@ module VagrantPlugins
|
|
87
85
|
def execute_on_vm(command, machine, opts = {})
|
88
86
|
@last_shell_command_output = {
|
89
87
|
stdout: '',
|
90
|
-
stderr: ''
|
88
|
+
stderr: ''
|
91
89
|
}
|
92
90
|
|
93
91
|
@last_shell_command_status = nil
|
94
92
|
|
95
93
|
machine.communicate.tap do |comm|
|
96
94
|
@last_shell_command_status = comm.execute(
|
97
|
-
command,
|
98
|
-
|
99
|
-
sudo: opts[:as_root]
|
100
|
-
}
|
95
|
+
command, error_check: false,
|
96
|
+
sudo: opts[:as_root]
|
101
97
|
) do |type, data|
|
102
98
|
if @vagrant_cucumber_debug
|
103
99
|
puts "[:#{type}] #{data.chomp}"
|
@@ -1,19 +1,52 @@
|
|
1
1
|
require 'to_regexp'
|
2
2
|
|
3
3
|
def push_snapshot(vmname)
|
4
|
-
|
4
|
+
case machine_provider(vmname)
|
5
|
+
when :libvirt
|
6
|
+
vagrant_glue.vagrant_env.cli('sandbox', 'on', vmname)
|
7
|
+
vagrant_glue.vagrant_env.cli('sandbox', 'commit', vmname)
|
8
|
+
when :no_machines
|
9
|
+
return
|
10
|
+
else
|
11
|
+
vagrant_glue.vagrant_env.cli('snapshot', 'push', vmname)
|
12
|
+
end
|
5
13
|
rescue Vagrant::Errors::EnvironmentLockedError
|
6
14
|
sleep 0.2
|
7
15
|
retry
|
16
|
+
rescue LoadError
|
17
|
+
raise 'Please install the `sahara` vagrant plugin.'
|
18
|
+
end
|
19
|
+
|
20
|
+
def snapshots_enabled?(vmname)
|
21
|
+
case machine_provider(vmname)
|
22
|
+
when :libvirt
|
23
|
+
require 'sahara/session/factory'
|
24
|
+
ses = Sahara::Session::Factory.create(vagrant_glue.get_vm(vmname))
|
25
|
+
ses.is_snapshot_mode_on?
|
26
|
+
when :no_machines
|
27
|
+
return false
|
28
|
+
else
|
29
|
+
machine = vagrant_glue.get_vm(vmname)
|
30
|
+
!machine.provider.capability(:snapshot_list).empty?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def machine_provider(vmname)
|
35
|
+
if vmname.nil?
|
36
|
+
return :no_machines if vagrant_glue.vagrant_env.active_machines.empty?
|
37
|
+
vagrant_glue.vagrant_env.active_machines[0][1]
|
38
|
+
else
|
39
|
+
vagrant_glue.get_vm(vmname).provider_name
|
40
|
+
end
|
8
41
|
end
|
9
42
|
|
10
43
|
def pop_snapshot(vmname = nil)
|
11
|
-
args =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
44
|
+
args = case machine_provider(vmname)
|
45
|
+
when :libvirt
|
46
|
+
%w(sandbox rollback)
|
47
|
+
else
|
48
|
+
%w(snapshot pop --no-provision --no-delete)
|
49
|
+
end
|
17
50
|
args << vmname unless vmname.nil?
|
18
51
|
|
19
52
|
vagrant_glue.vagrant_env.cli(*args)
|
@@ -24,14 +57,12 @@ end
|
|
24
57
|
|
25
58
|
Given /^there is a running VM called "([^"]*)"$/ do |vmname|
|
26
59
|
machine = vagrant_glue.get_vm(vmname)
|
27
|
-
|
28
60
|
machine.action(:up)
|
29
|
-
|
30
|
-
push_snapshot(vmname) if machine.provider.capability(:snapshot_list).empty?
|
61
|
+
push_snapshot(vmname) unless snapshots_enabled?(vmname)
|
31
62
|
end
|
32
63
|
|
33
64
|
When /^I roll back the VM called "([^"]*)"$/ do |vmname|
|
34
|
-
|
65
|
+
_machine = vagrant_glue.get_vm(vmname)
|
35
66
|
|
36
67
|
pop_snapshot(vmname)
|
37
68
|
end
|
@@ -39,7 +70,7 @@ end
|
|
39
70
|
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})(?:|, it) should (succeed|fail)$/ do |command, as_root, vmre, condition|
|
40
71
|
options = {
|
41
72
|
as_root: (as_root == ' as root'),
|
42
|
-
expect_non_zero: (condition == 'fail')
|
73
|
+
expect_non_zero: (condition == 'fail')
|
43
74
|
}
|
44
75
|
|
45
76
|
options[:expect] = 0 if condition == 'succeed'
|
@@ -54,7 +85,7 @@ end
|
|
54
85
|
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})$/ do |command, as_root, vmre|
|
55
86
|
options = {
|
56
87
|
machine: vagrant_glue.identified_vm(vmre),
|
57
|
-
as_root: (as_root == ' as root')
|
88
|
+
as_root: (as_root == ' as root')
|
58
89
|
}
|
59
90
|
|
60
91
|
vagrant_glue.execute_on_vm(
|
@@ -64,7 +95,7 @@ Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})$/ do |comm
|
|
64
95
|
)
|
65
96
|
end
|
66
97
|
|
67
|
-
Then /^the (.+) of that shell command should(| not) match (\/.+\/)$/ do |stream, condition, re|
|
98
|
+
Then %r{/^the (.+) of that shell command should(| not) match (\/.+\/)$/} do |stream, condition, re|
|
68
99
|
stream.downcase!
|
69
100
|
|
70
101
|
unless vagrant_glue.last_shell_command_output.key?(stream.to_sym)
|
data/vagrant-cucumber.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
3
|
require 'vagrant-cucumber/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
@@ -24,8 +24,9 @@ Gem::Specification.new do |s|
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
s.add_runtime_dependency 'cucumber', '~>
|
28
|
-
s.add_runtime_dependency 'to_regexp', '
|
27
|
+
s.add_runtime_dependency 'cucumber', '~>2.4'
|
28
|
+
s.add_runtime_dependency 'to_regexp', '~>0.2.1'
|
29
|
+
s.add_runtime_dependency 'sahara', '~>0.0.17'
|
29
30
|
|
30
31
|
s.files = files
|
31
32
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Topper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: to_regexp
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.2.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sahara
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.17
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.17
|
41
55
|
description: This plugin makes it possible for Cucumber to interact with Vagrant
|
42
56
|
email:
|
43
57
|
- jon@scalefactory.com
|
@@ -45,6 +59,7 @@ executables: []
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
62
|
+
- ".rubocop.yml"
|
48
63
|
- CHANGELOG.md
|
49
64
|
- CONTRIBUTING.md
|
50
65
|
- LICENSE
|