vagrant-cucumber 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +11 -5
- data/LICENSE +1 -1
- data/README.md +31 -34
- data/example/Vagrantfile +6 -6
- data/lib/vagrant-cucumber/commands/cucumber.rb +13 -5
- data/lib/vagrant-cucumber/cucumber/formatter/html.rb +2 -12
- data/lib/vagrant-cucumber/cucumber/formatter/pretty.rb +0 -10
- data/lib/vagrant-cucumber/glue.rb +18 -45
- data/lib/vagrant-cucumber/plugin.rb +7 -11
- data/lib/vagrant-cucumber/step_definitions.rb +53 -47
- data/lib/vagrant-cucumber/version.rb +3 -3
- data/lib/vagrant-cucumber.rb +6 -6
- data/vagrant-cucumber.gemspec +24 -26
- metadata +9 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57634e161f698537816146c12edbec81975b6fbe
|
4
|
+
data.tar.gz: 142c2e58f896134d3d9b1fbacee8e1d21ef299cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1abfea63a425e331044613e5d3057a83acfad59989bbdbf41e4a42fd82be97f64b5eadd71206cbcd8c26947ec4b6e7c5ab54ca59b8988033075db95aaf338795
|
7
|
+
data.tar.gz: 648f16d2dec025ef169e97843cc6929c9fd12b04e32c555485293c90b2479ee4c992bd325eb1ff4f725393cab85ddb5acfcb0a3ab816aad2812acbf1f9305b03
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.1.0 (21 July, 2016)
|
2
|
+
|
3
|
+
* Removed `vagrant-multiprovider-snap` dependency. Vagrant now has all
|
4
|
+
required features.
|
5
|
+
* Updates to various syntax in the code.
|
6
|
+
* "New" style Ruby hashes (no hash rockets).
|
7
|
+
* Removal of some deprecated methods (`Hash#has_key?`, etc)
|
8
|
+
* Quick sweep with `rubocop` to fix some minor style issues.
|
9
|
+
* Fixes to `README.md`, mostly removal of references to
|
10
|
+
`vagrant-multiprovider-snap` with some markdown cleanups.
|
11
|
+
|
1
12
|
## 0.0.10 (May 6, 2015)
|
2
13
|
|
3
14
|
* Fixed gemspec to constrain cucumber version
|
data/CONTRIBUTING.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Contributing to vagrant-cucumber
|
2
2
|
================================
|
3
3
|
|
4
|
-
We welcome contributions to vagrant-cucumber, either to fix bugs or to add new
|
4
|
+
We welcome contributions to vagrant-cucumber, either to fix bugs or to add new
|
5
|
+
features.
|
5
6
|
|
6
7
|
Patch workflow
|
7
8
|
--------------
|
@@ -15,18 +16,23 @@ Patch workflow
|
|
15
16
|
Working with the code
|
16
17
|
---------------------
|
17
18
|
|
18
|
-
We use Bundler to manage the development environment with the latest version of
|
19
|
+
We use Bundler to manage the development environment with the latest version of
|
20
|
+
Vagrant and its dependencies. Assuming you have Bundler installed, running
|
21
|
+
`bundle install` in the project root will set the environment up for you.
|
19
22
|
|
20
23
|
|
21
24
|
Testing
|
22
25
|
-------
|
23
26
|
|
24
|
-
vagrant-cucumber is a reasonably thin glue layer, so doesn't need a whole lot
|
27
|
+
`vagrant-cucumber` is a reasonably thin glue layer, so doesn't need a whole lot
|
28
|
+
of testing in its current incarnation. As long as the published example
|
29
|
+
features work, you can be confident your changes haven't broken anything. To
|
30
|
+
test this, run:
|
25
31
|
|
26
32
|
```
|
27
33
|
cd example
|
28
34
|
bundle exec vagrant cucumber
|
29
35
|
```
|
30
36
|
|
31
|
-
If you add any new behaviour to vagrant-cucumber
|
32
|
-
the
|
37
|
+
If you add any new behaviour to `vagrant-cucumber`, please add a feature file
|
38
|
+
to the `example/` folder which demonstrates how to use it.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,8 +4,8 @@ Vagrant Cucumber
|
|
4
4
|
Description
|
5
5
|
-----------
|
6
6
|
|
7
|
-
This plugin allows Vagrant to run
|
8
|
-
for working with
|
7
|
+
This plugin allows Vagrant to run Cucumber features, and provides some glue
|
8
|
+
for working with Vagrant boxes within your Cucumber steps.
|
9
9
|
|
10
10
|
It was originally developed to help us test configuration management scripts,
|
11
11
|
and with the following workflow in mind:
|
@@ -13,7 +13,7 @@ and with the following workflow in mind:
|
|
13
13
|
* Start one or more Vagrant boxes
|
14
14
|
* Configure these boxes with some default state
|
15
15
|
* Snapshot each box in this default state.
|
16
|
-
* In each
|
16
|
+
* In each Cucumber scenario
|
17
17
|
- Run config management tools inside the box to make configuration changes
|
18
18
|
- Test that these changes produce the desired result
|
19
19
|
- Roll the VM state back, ready for the next scenario
|
@@ -22,8 +22,10 @@ and with the following workflow in mind:
|
|
22
22
|
Requirements
|
23
23
|
------------
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
Since `0.1.x` this plugin requires a minimum Vagrant version of `1.8.4`.
|
26
|
+
|
27
|
+
The plugin requires the `cucumber` gem, but will install this itself if
|
28
|
+
required.
|
27
29
|
|
28
30
|
Vagrant Cucumber currently works only with the current Vagrant providers:
|
29
31
|
|
@@ -31,30 +33,26 @@ Vagrant Cucumber currently works only with the current Vagrant providers:
|
|
31
33
|
* VMWare Fusion (using the commercial VMWare plugin for Vagrant)
|
32
34
|
|
33
35
|
|
34
|
-
|
35
36
|
Installation
|
36
37
|
------------
|
37
38
|
|
38
|
-
Assuming you're running the packaged version of Vagrant, the easiest way to
|
39
|
+
Assuming you're running the packaged version of Vagrant, the easiest way to
|
39
40
|
install this plugin is via the published gem:
|
40
41
|
|
41
42
|
```
|
42
43
|
vagrant plugin install vagrant-cucumber
|
43
44
|
```
|
44
45
|
|
45
|
-
|
46
|
-
vagrant-multiprovider-snap plugin if you don't already have it.
|
47
|
-
|
48
|
-
vagrant-cucumber will also install a version of cucumber >= 1.3.2 under the
|
46
|
+
`vagrant-cucumber` will install a version of cucumber >= 1.3.2 under the
|
49
47
|
Ruby environment provided by Vagrant.
|
50
48
|
|
51
49
|
|
52
50
|
Usage
|
53
51
|
-----
|
54
52
|
|
55
|
-
This plugin adds a subcommand,
|
56
|
-
the usual
|
57
|
-
cucumber for details, or use
|
53
|
+
This plugin adds a subcommand, `vagrant cucumber` - this simply wraps
|
54
|
+
the usual `cucumber` command line handler. Refer to the documentation for
|
55
|
+
cucumber for details, or use `vagrant cucumber -h` for a full list of
|
58
56
|
options.
|
59
57
|
|
60
58
|
|
@@ -67,51 +65,50 @@ a Vagrantfile and features directory which demonstrates the plugin in action.
|
|
67
65
|
The Vagrantfile defines two basic VMs which will be used to run our tests.
|
68
66
|
It will work with either the Virtualbox or the VMWare Fusion provider.
|
69
67
|
|
70
|
-
Use
|
68
|
+
Use `vagrant up` in that folder in order to start the default VM. (In the
|
71
69
|
current version of the plugin, VMs must be running before they can be used
|
72
|
-
in tests). If you don't already have the standard precise64 vagrant box, it
|
70
|
+
in tests). If you don't already have the standard `precise64` vagrant box, it
|
73
71
|
will be fetched from the Vagrant website. If you prefer to use the VMWare
|
74
|
-
provider, add
|
72
|
+
provider, add `--provider=vmware_fusion` to the commandline.
|
75
73
|
|
76
|
-
To run all the tests, run
|
74
|
+
To run all the tests, run:
|
77
75
|
|
78
|
-
|
76
|
+
`vagrant cucumber`.
|
79
77
|
|
80
|
-
The tests are split between multiple feature files. You can run one feature
|
78
|
+
The tests are split between multiple feature files. You can run one feature
|
81
79
|
file at a time by specifying it on the commandline:
|
82
80
|
|
83
|
-
|
81
|
+
`vagrant cucumber features/basic.feature`
|
84
82
|
|
85
|
-
|
86
|
-
both as the standard vagrant user, and as root
|
87
|
-
that snapshot rollback is working correctly.
|
83
|
+
`basic.feature` demonstrates running basic shell commands inside the VM
|
84
|
+
both as the standard `vagrant` user, and as `root`. It also contains a test to
|
85
|
+
show that snapshot rollback is working correctly.
|
88
86
|
|
89
|
-
|
87
|
+
`multivm.feature` shows how steps can reference different VMs. For details
|
90
88
|
on how to write your own step definitions which can work on multiple VMs,
|
91
89
|
see the next section.
|
92
90
|
|
93
|
-
The test in
|
94
|
-
The test scenario is preceded with the tag
|
91
|
+
The test in `multivm.feature` also demonstrates use of cucumber tags.
|
92
|
+
The test scenario is preceded with the tag `@vagrant-cucumber-debug`. This
|
95
93
|
causes debug output to be emitted.
|
96
94
|
|
97
|
-
We also provide a
|
95
|
+
We also provide a `@norollback` tag, which prevents the VMs from being
|
98
96
|
rolled back at the end of the scenario. This is useful for debugging.
|
99
97
|
|
100
98
|
|
101
|
-
|
102
99
|
Implementation Detail
|
103
100
|
---------------------
|
104
101
|
|
105
102
|
The best place to gain an understanding of the implementation of Cucumber steps
|
106
|
-
is in
|
103
|
+
is in `example/features/step_definitions/process.rb`. I've heavily
|
107
104
|
commented this in order to be a good working example.
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
Other step definitions and hooks are defined in ```lib/vagrant-cucumber/step_definitions.rb```.
|
106
|
+
`example/features/process.feature` uses these step definitions.
|
112
107
|
|
108
|
+
Other step definitions and hooks are defined in
|
109
|
+
`lib/vagrant-cucumber/step_definitions.rb`.
|
113
110
|
|
114
111
|
|
115
112
|
License
|
116
113
|
-------
|
117
|
-
vagrant-cucumber is licensed under the MIT license.
|
114
|
+
`vagrant-cucumber` is licensed under the MIT license.
|
data/example/Vagrantfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
Vagrant.configure(
|
1
|
+
Vagrant.configure('2') do |config|
|
2
|
+
config.vm.box = "ubuntu/precise64"
|
2
3
|
|
3
|
-
config.vm.
|
4
|
-
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
4
|
+
config.vm.provider :virtualbox
|
5
5
|
|
6
|
-
config.vm.provider :vmware_fusion do |fusion,override|
|
7
|
-
|
8
|
-
override.vm.
|
6
|
+
config.vm.provider :vmware_fusion do |fusion, override|
|
7
|
+
# Standard Ubuntu image doesn't exist for VMWare
|
8
|
+
override.vm.box = "hashicorp/precise64"
|
9
9
|
end
|
10
10
|
|
11
11
|
config.vm.define :vm1 do |vm1|
|
@@ -1,9 +1,20 @@
|
|
1
|
+
FORCE_COLOUR_ENV_VARS = [
|
2
|
+
'VAGRANT_CUCUMBER_FORCE_COLOR',
|
3
|
+
'VAGRANT_CUCUMBER_FORCE_COLOUR',
|
4
|
+
]
|
5
|
+
|
1
6
|
module VagrantPlugins
|
2
7
|
module Cucumber
|
3
8
|
class CucumberCommand < Vagrant.plugin(2, :command)
|
9
|
+
FORCE_COLOUR_ENV_VARS.each do |k|
|
10
|
+
if ENV.key?(k)
|
11
|
+
require 'cucumber/term/ansicolor'
|
12
|
+
::Cucumber::Term::ANSIColor.coloring = true
|
13
|
+
break
|
14
|
+
end
|
15
|
+
end
|
4
16
|
|
5
17
|
def execute
|
6
|
-
|
7
18
|
require 'cucumber/rspec/disable_option_parser'
|
8
19
|
require 'cucumber/cli/main'
|
9
20
|
|
@@ -13,11 +24,8 @@ module VagrantPlugins
|
|
13
24
|
|
14
25
|
VagrantPlugins::Cucumber::Glue::VagrantGlue.set_environment(@env)
|
15
26
|
|
16
|
-
failure = ::Cucumber::Cli::Main.execute(@argv)
|
17
|
-
|
27
|
+
failure = ::Cucumber::Cli::Main.execute(@argv)
|
18
28
|
end
|
19
|
-
|
20
29
|
end
|
21
30
|
end
|
22
31
|
end
|
23
|
-
|
@@ -2,29 +2,19 @@ require 'cucumber/formatter/html'
|
|
2
2
|
|
3
3
|
ANSI_PATTERN = /\e\[(\d+)?(;\d+)?m/
|
4
4
|
|
5
|
-
def remove_ansi(string=nil)
|
5
|
+
def remove_ansi(string = nil)
|
6
6
|
string.gsub(ANSI_PATTERN, '')
|
7
7
|
end
|
8
8
|
|
9
9
|
module VagrantPlugins
|
10
|
-
|
11
10
|
module Cucumber
|
12
|
-
|
13
11
|
module Formatter
|
14
|
-
|
15
12
|
class Html < ::Cucumber::Formatter::Html
|
16
|
-
|
17
13
|
def puts(message)
|
18
|
-
# TODO Strip ansi escape codes
|
14
|
+
# TODO: Strip ansi escape codes
|
19
15
|
@delayed_messages << remove_ansi(message)
|
20
16
|
end
|
21
|
-
|
22
17
|
end
|
23
|
-
|
24
18
|
end
|
25
|
-
|
26
19
|
end
|
27
|
-
|
28
20
|
end
|
29
|
-
|
30
|
-
|
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'cucumber/formatter/pretty'
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
|
-
|
5
4
|
module Cucumber
|
6
|
-
|
7
5
|
module Formatter
|
8
|
-
|
9
6
|
class Pretty < ::Cucumber::Formatter::Pretty
|
10
|
-
|
11
7
|
# Use the Pretty formatter, but disable use of
|
12
8
|
# delayed messages (ie. output each line at once)
|
13
9
|
|
@@ -24,13 +20,7 @@ module VagrantPlugins
|
|
24
20
|
|
25
21
|
def print_table_row_messages
|
26
22
|
end
|
27
|
-
|
28
23
|
end
|
29
|
-
|
30
24
|
end
|
31
|
-
|
32
25
|
end
|
33
|
-
|
34
26
|
end
|
35
|
-
|
36
|
-
|
@@ -3,11 +3,8 @@ unless defined?(VMRE)
|
|
3
3
|
end
|
4
4
|
|
5
5
|
module VagrantPlugins
|
6
|
-
|
7
6
|
module Cucumber
|
8
|
-
|
9
7
|
module Glue
|
10
|
-
|
11
8
|
# This glue module will be used in the cucumber World for
|
12
9
|
# tests run with vagrant-cucumber. It's used to hide interaction
|
13
10
|
# with the messier parts of the vagrant environment so the
|
@@ -18,7 +15,6 @@ module VagrantPlugins
|
|
18
15
|
end
|
19
16
|
|
20
17
|
class VagrantGlue
|
21
|
-
|
22
18
|
@@vagrant_env = nil
|
23
19
|
|
24
20
|
def self.set_environment(env)
|
@@ -26,10 +22,8 @@ module VagrantPlugins
|
|
26
22
|
end
|
27
23
|
|
28
24
|
def initialize
|
29
|
-
|
30
25
|
@vagrant_env = @@vagrant_env or raise "The vagrant_env hasn't been set"
|
31
26
|
@last_machine_mentioned = nil
|
32
|
-
|
33
27
|
end
|
34
28
|
|
35
29
|
def self.instance
|
@@ -41,110 +35,89 @@ module VagrantPlugins
|
|
41
35
|
end
|
42
36
|
|
43
37
|
def get_last_vm
|
44
|
-
get_vm(
|
38
|
+
get_vm(@last_machine_mentioned)
|
45
39
|
end
|
46
40
|
|
47
|
-
def get_vm(
|
48
|
-
|
41
|
+
def get_vm(vmname)
|
49
42
|
machine_provider = nil
|
50
43
|
machine_name = nil
|
51
44
|
|
52
45
|
# If this machine name is not configured, blow up
|
53
|
-
|
54
|
-
raise Vagrant::Errors::VMNotFoundError, :
|
46
|
+
unless @vagrant_env.machine_names.index(vmname.to_sym)
|
47
|
+
raise Vagrant::Errors::VMNotFoundError, name: vmname
|
55
48
|
end
|
56
49
|
|
57
50
|
@vagrant_env.active_machines.each do |a_name, a_provider|
|
58
|
-
|
59
51
|
if a_name == vmname.to_sym
|
60
52
|
machine_provider = a_provider
|
61
53
|
machine_name = a_name
|
62
54
|
end
|
63
|
-
|
64
55
|
end
|
65
56
|
|
66
|
-
|
67
|
-
|
57
|
+
unless machine_name
|
68
58
|
raise "The VM '#{vmname}' is configured in the Vagrantfile "+
|
69
59
|
"but has not been started. Run 'vagrant up #{vmname}' and "+
|
70
60
|
"specify a provider if necessary."
|
71
|
-
|
72
61
|
end
|
73
62
|
|
74
63
|
machine_provider ||= vagrant_env.default_provider
|
75
|
-
|
76
|
-
|
64
|
+
|
65
|
+
machine = @vagrant_env.machine(
|
66
|
+
machine_name,
|
67
|
+
machine_provider
|
77
68
|
)
|
78
69
|
|
79
70
|
@last_machine_mentioned = vmname
|
80
71
|
|
81
72
|
machine
|
82
|
-
|
83
73
|
end
|
84
74
|
|
85
|
-
def identified_vm(
|
75
|
+
def identified_vm(str)
|
86
76
|
case str
|
87
77
|
when /^( on the last VM|)$/
|
88
78
|
get_last_vm
|
89
79
|
when /^ on the VM(?: called|) "([^"]+)"$/
|
90
|
-
get_vm(
|
80
|
+
get_vm($1)
|
91
81
|
end
|
92
82
|
end
|
93
83
|
|
94
|
-
|
95
84
|
attr_reader :last_shell_command_status
|
96
85
|
attr_reader :last_shell_command_output
|
97
86
|
|
98
|
-
def execute_on_vm
|
99
|
-
|
87
|
+
def execute_on_vm(command, machine, opts = {})
|
100
88
|
@last_shell_command_output = {
|
101
|
-
:
|
102
|
-
:
|
89
|
+
stdout: '',
|
90
|
+
stderr: '',
|
103
91
|
}
|
104
92
|
|
105
93
|
@last_shell_command_status = nil
|
106
94
|
|
107
95
|
machine.communicate.tap do |comm|
|
108
|
-
|
109
96
|
@last_shell_command_status = comm.execute(
|
110
97
|
command, {
|
111
|
-
:
|
112
|
-
:
|
98
|
+
error_check: false,
|
99
|
+
sudo: opts[:as_root]
|
113
100
|
}
|
114
|
-
) do |type,data|
|
115
|
-
|
101
|
+
) do |type, data|
|
116
102
|
if @vagrant_cucumber_debug
|
117
103
|
puts "[:#{type}] #{data.chomp}"
|
118
104
|
end
|
119
105
|
|
120
106
|
@last_shell_command_output[type] += data
|
121
|
-
|
122
107
|
end
|
123
|
-
|
124
108
|
end
|
125
109
|
|
126
110
|
if opts[:expect_nonzero]
|
127
|
-
|
128
111
|
if @last_shell_command_status != 0
|
129
112
|
raise "Expected command to return non-zero, got #{@last_shell_command_status}"
|
130
113
|
end
|
131
|
-
|
132
|
-
elsif opts.has_key?(:expect)
|
133
|
-
|
114
|
+
elsif opts.key?(:expect)
|
134
115
|
if @last_shell_command_status != opts[:expect]
|
135
116
|
raise "Expected command to return #{opts[:expect]}, got #{@last_shell_command_status}"
|
136
117
|
end
|
137
|
-
|
138
118
|
end
|
139
|
-
|
140
119
|
end
|
141
|
-
|
142
120
|
end
|
143
|
-
|
144
|
-
|
145
121
|
end
|
146
|
-
|
147
122
|
end
|
148
|
-
|
149
123
|
end
|
150
|
-
|
@@ -1,26 +1,22 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require 'vagrant'
|
3
3
|
rescue LoadError
|
4
|
-
raise
|
4
|
+
raise 'The Vagrant Cucumber plugin must be run within Vagrant.'
|
5
5
|
end
|
6
6
|
|
7
7
|
module VagrantPlugins
|
8
|
-
module Cucumber
|
9
|
-
class Plugin < Vagrant.plugin(
|
10
|
-
|
11
|
-
require 'vagrant-multiprovider-snap'
|
12
|
-
|
13
|
-
name "Cucumber"
|
8
|
+
module Cucumber
|
9
|
+
class Plugin < Vagrant.plugin('2')
|
10
|
+
name 'Cucumber'
|
14
11
|
|
15
12
|
description <<-DESC
|
16
13
|
This plugin makes it possible for Cucumber to interact with Vagrant
|
17
14
|
DESC
|
18
15
|
|
19
|
-
command
|
20
|
-
require_relative
|
16
|
+
command 'cucumber' do
|
17
|
+
require_relative 'commands/cucumber'
|
21
18
|
CucumberCommand
|
22
19
|
end
|
23
|
-
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
@@ -1,94 +1,100 @@
|
|
1
1
|
require 'to_regexp'
|
2
2
|
|
3
3
|
Given /^there is a running VM called "([^"]*)"$/ do |vmname|
|
4
|
-
|
5
|
-
machine = vagrant_glue.get_vm( vmname )
|
4
|
+
machine = vagrant_glue.get_vm(vmname)
|
6
5
|
|
7
6
|
machine.action(:up)
|
8
7
|
|
9
|
-
|
10
|
-
vagrant_glue.vagrant_env.cli('
|
8
|
+
if machine.provider.capability(:snapshot_list).empty?
|
9
|
+
vagrant_glue.vagrant_env.cli('snapshot', 'push', vmname)
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
14
12
|
|
15
13
|
When /^I roll back the VM called "([^"]*)"$/ do |vmname|
|
16
|
-
|
17
|
-
|
18
|
-
vagrant_glue.vagrant_env.cli(
|
19
|
-
|
14
|
+
machine = vagrant_glue.get_vm(vmname)
|
15
|
+
|
16
|
+
vagrant_glue.vagrant_env.cli(
|
17
|
+
'snapshot',
|
18
|
+
'pop',
|
19
|
+
'--no-provision',
|
20
|
+
'--no-delete',
|
21
|
+
vmname,
|
22
|
+
)
|
20
23
|
end
|
21
24
|
|
22
|
-
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})(?:|, it) should (succeed|fail)$/ do |command,as_root,vmre,condition|
|
23
|
-
|
25
|
+
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})(?:|, it) should (succeed|fail)$/ do |command, as_root, vmre, condition|
|
24
26
|
options = {
|
25
|
-
:
|
26
|
-
:
|
27
|
-
}
|
28
|
-
|
29
|
-
if condition == 'succeed'
|
30
|
-
options[:expect] = 0
|
31
|
-
end
|
27
|
+
as_root: (as_root == ' as root'),
|
28
|
+
expect_non_zero: (condition == 'fail'),
|
29
|
+
}
|
32
30
|
|
33
|
-
|
31
|
+
options[:expect] = 0 if condition == 'succeed'
|
34
32
|
|
33
|
+
vagrant_glue.execute_on_vm(
|
34
|
+
command,
|
35
|
+
vagrant_glue.identified_vm(vmre),
|
36
|
+
options
|
37
|
+
)
|
35
38
|
end
|
36
39
|
|
37
|
-
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})$/ do |command,as_root,vmre|
|
38
|
-
|
40
|
+
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})$/ do |command, as_root, vmre|
|
39
41
|
options = {
|
40
|
-
:
|
41
|
-
:
|
42
|
+
machine: vagrant_glue.identified_vm(vmre),
|
43
|
+
as_root: (as_root == ' as root'),
|
42
44
|
}
|
43
45
|
|
44
|
-
vagrant_glue.execute_on_vm(
|
45
|
-
|
46
|
+
vagrant_glue.execute_on_vm(
|
47
|
+
command,
|
48
|
+
vagrant_glue.identified_vm(vmre),
|
49
|
+
options
|
50
|
+
)
|
46
51
|
end
|
47
52
|
|
48
|
-
|
49
|
-
Then /^the (.+) of that shell command should(| not) match (\/.+\/)$/ do |stream,condition,re|
|
50
|
-
|
53
|
+
Then /^the (.+) of that shell command should(| not) match (\/.+\/)$/ do |stream, condition, re|
|
51
54
|
stream.downcase!
|
52
55
|
|
53
|
-
unless vagrant_glue.last_shell_command_output.
|
56
|
+
unless vagrant_glue.last_shell_command_output.key?(stream.to_sym)
|
54
57
|
raise "vagrant_glue.last_shell_command_output structure has no #{stream}"
|
55
58
|
end
|
56
59
|
|
57
|
-
re_result = (
|
60
|
+
re_result = (
|
61
|
+
vagrant_glue.last_shell_command_output[stream.to_sym] =~ re.to_regexp
|
62
|
+
)
|
63
|
+
|
58
64
|
re_matched = !re_result.nil?
|
59
65
|
|
60
66
|
should_match = condition != ' not'
|
61
67
|
|
62
|
-
if re_matched
|
68
|
+
if re_matched && !should_match
|
63
69
|
raise "Regular expression matched, but shouldn't have"
|
64
70
|
end
|
65
71
|
|
66
|
-
if !re_matched
|
72
|
+
if !re_matched && should_match
|
67
73
|
raise "Regular expression didn't match, but should have"
|
68
74
|
end
|
69
|
-
|
70
75
|
end
|
71
76
|
|
72
|
-
Before('@norollback') do |
|
73
|
-
puts
|
77
|
+
Before('@norollback') do |_scenario|
|
78
|
+
puts 'Saw @norollback tag:'
|
74
79
|
puts " * Won't roll back snapshot at end of scenario"
|
75
|
-
puts
|
80
|
+
puts ' * Will roll back explicit snapshots in the scenario'
|
76
81
|
end
|
77
82
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
After('~@norollback') do |_scenario|
|
84
|
+
puts 'Rolling back VM states'
|
85
|
+
vagrant_glue.vagrant_env.cli(
|
86
|
+
'snapshot',
|
87
|
+
'pop',
|
88
|
+
'--no-provision',
|
89
|
+
'--no-delete',
|
90
|
+
)
|
85
91
|
end
|
86
92
|
|
87
|
-
After('@norollback') do |
|
88
|
-
puts
|
93
|
+
After('@norollback') do |_scenario|
|
94
|
+
puts 'Saw @norollback tag - not rolling back'
|
89
95
|
end
|
90
96
|
|
91
|
-
Before('@vagrant-cucumber-debug') do |
|
92
|
-
puts
|
97
|
+
Before('@vagrant-cucumber-debug') do |_scenario|
|
98
|
+
puts 'Enabling debugging for vagrant-cucumber scenarios'
|
93
99
|
@vagrant_cucumber_debug = true
|
94
100
|
end
|
data/lib/vagrant-cucumber.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'vagrant-cucumber/version'
|
2
|
+
require 'vagrant-cucumber/plugin'
|
3
|
+
require 'vagrant-cucumber/glue'
|
4
4
|
|
5
5
|
module VagrantPlugins
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
module Cucumber
|
7
|
+
# ...
|
8
|
+
end
|
9
9
|
end
|
data/vagrant-cucumber.gemspec
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'vagrant-cucumber/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
s.name = 'vagrant-cucumber'
|
7
|
+
s.version = VagrantPlugins::Cucumber::VERSION
|
8
|
+
s.authors = ['Jon Topper']
|
9
|
+
s.email = ['jon@scalefactory.com']
|
10
|
+
s.homepage = 'https://github.com/scalefactory/vagrant-cucumber'
|
11
|
+
s.summary = 'Cucumber support for Vagrant'
|
12
|
+
s.description = 'This plugin makes it possible for Cucumber to interact with Vagrant'
|
13
|
+
s.license = 'MIT'
|
14
14
|
|
15
|
-
|
15
|
+
s.rubyforge_project = 'vagrant-cucumber'
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
files = `git ls-files`.split("\n")
|
18
|
+
ignore = %w(Gemfile Rakefile .gitignore)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
s.add_runtime_dependency "cucumber", "~>1.3.2"
|
28
|
-
s.add_runtime_dependency "vagrant-multiprovider-snap", ">=0.0.4"
|
29
|
-
s.add_runtime_dependency "to_regexp", ">=0.2.1"
|
20
|
+
files.delete_if do |f|
|
21
|
+
ignore.any? do |i|
|
22
|
+
File.fnmatch(i, f, File::FNM_PATHNAME) ||
|
23
|
+
File.fnmatch(i, File.basename(f), File::FNM_PATHNAME)
|
24
|
+
end
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
s.require_paths = ["lib"]
|
27
|
+
s.add_runtime_dependency 'cucumber', '~>1.3.2'
|
28
|
+
s.add_runtime_dependency 'to_regexp', '>=0.2.1'
|
34
29
|
|
30
|
+
s.files = files
|
31
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
32
|
+
s.require_paths = ['lib']
|
35
33
|
end
|
metadata
CHANGED
@@ -1,55 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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:
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.3.2
|
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
26
|
version: 1.3.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: vagrant-multiprovider-snap
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.4
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.4
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: to_regexp
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
33
|
version: 0.2.1
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: 0.2.1
|
55
41
|
description: This plugin makes it possible for Cucumber to interact with Vagrant
|
@@ -88,17 +74,17 @@ require_paths:
|
|
88
74
|
- lib
|
89
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
76
|
requirements:
|
91
|
-
- -
|
77
|
+
- - ">="
|
92
78
|
- !ruby/object:Gem::Version
|
93
79
|
version: '0'
|
94
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
81
|
requirements:
|
96
|
-
- -
|
82
|
+
- - ">="
|
97
83
|
- !ruby/object:Gem::Version
|
98
84
|
version: '0'
|
99
85
|
requirements: []
|
100
86
|
rubyforge_project: vagrant-cucumber
|
101
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.4.5.1
|
102
88
|
signing_key:
|
103
89
|
specification_version: 4
|
104
90
|
summary: Cucumber support for Vagrant
|