vagrant-cucumber 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +32 -0
- data/example/Vagrantfile +2 -0
- data/example/features/basic.feature +6 -7
- data/lib/vagrant-cucumber/glue.rb +48 -0
- data/lib/vagrant-cucumber/plugin.rb +2 -0
- data/lib/vagrant-cucumber/step_definitions.rb +19 -31
- data/lib/vagrant-cucumber/version.rb +1 -1
- data/vagrant-cucumber.gemspec +1 -0
- metadata +11 -9
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 0.0.4 (August 8, 2013)
|
2
|
+
|
3
|
+
* Added missing license detail to Gem spec
|
4
|
+
* Improve use of Given/When/Then in examples as per idiomatic Cucumber usage
|
5
|
+
* Refactor to get shell runner helper into the glue and out of the step definitions
|
6
|
+
* Added details on how to contribute to the project
|
7
|
+
|
8
|
+
With thanks to Matt Wynne (@mattwynne) for feedback
|
9
|
+
|
1
10
|
## 0.0.3 (July 26, 2013)
|
2
11
|
|
3
12
|
* Update dependencies for vagrant-multiprovider-snap
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Contributing to vagrant-cucumber
|
2
|
+
================================
|
3
|
+
|
4
|
+
We welcome contributions to vagrant-cucumber, either to fix bugs or to add new features.
|
5
|
+
|
6
|
+
Patch workflow
|
7
|
+
--------------
|
8
|
+
|
9
|
+
* Fork the project.
|
10
|
+
* Create a branch for your changes.
|
11
|
+
* Don't modify the version number or changelog - we'll do that on release.
|
12
|
+
* Send a pull request
|
13
|
+
|
14
|
+
|
15
|
+
Working with the code
|
16
|
+
---------------------
|
17
|
+
|
18
|
+
We use Bundler to manage the development environment with the latest version of Vagrant and its dependencies. Assuming you have Bundler installed, running ```bundle install``` in the project root will set the environment up for you.
|
19
|
+
|
20
|
+
|
21
|
+
Testing
|
22
|
+
-------
|
23
|
+
|
24
|
+
vagrant-cucumber is a reasonably thin glue layer, so doesn't need a whole lot of testing in its current incarnation. As long as the published example features work, you can be confident your changes haven't broken anything. To test this, run:
|
25
|
+
|
26
|
+
```
|
27
|
+
cd example
|
28
|
+
bundle exec vagrant cucumber
|
29
|
+
```
|
30
|
+
|
31
|
+
If you add any new behaviour to vagrant-cucumber, please add a feature file to
|
32
|
+
the ```example/``` folder which demonstrates how to use it.
|
data/example/Vagrantfile
CHANGED
@@ -3,8 +3,8 @@ Feature: VM Running
|
|
3
3
|
Scenario: Check we can run simple commands
|
4
4
|
|
5
5
|
Given there is a running VM called "vm1"
|
6
|
-
|
7
|
-
|
6
|
+
When I run the shell command `id`
|
7
|
+
Then the stdout of that shell command should match /vagrant/
|
8
8
|
And the stdout of that shell command should not match /root/
|
9
9
|
And the stderr of that shell command should match /^$/
|
10
10
|
|
@@ -12,19 +12,18 @@ Feature: VM Running
|
|
12
12
|
Scenario: Check we can run commands as root
|
13
13
|
|
14
14
|
Given there is a running VM called "vm1"
|
15
|
-
|
16
|
-
|
15
|
+
When I run the shell command `id` as root
|
16
|
+
Then the stdout of that shell command should match /root/
|
17
17
|
And the stdout of that shell command should not match /vagrant/
|
18
18
|
|
19
19
|
|
20
20
|
Scenario: Write a file so that we can check we're rolling back properly
|
21
21
|
|
22
22
|
Given there is a running VM called "vm1"
|
23
|
-
|
24
23
|
Then running the shell command `grep test /tmp/cucumber-written-file` should fail
|
25
24
|
|
26
|
-
When I run the shell command `echo test > /tmp/cucumber-written-file
|
27
|
-
|
25
|
+
When I run the shell command `echo test > /tmp/cucumber-written-file`
|
26
|
+
Then running the shell command `grep test /tmp/cucumber-written-file` should succeed
|
28
27
|
|
29
28
|
When I roll back the VM called "vm1"
|
30
29
|
Then running the shell command `grep test /tmp/cucumber-written-file` should fail
|
@@ -88,6 +88,54 @@ module VagrantPlugins
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
|
92
|
+
attr_reader :last_shell_command_status
|
93
|
+
attr_reader :last_shell_command_output
|
94
|
+
|
95
|
+
def execute_on_vm ( command, machine, opts = {} )
|
96
|
+
|
97
|
+
@last_shell_command_output = {
|
98
|
+
:stdout => '',
|
99
|
+
:stderr => '',
|
100
|
+
}
|
101
|
+
|
102
|
+
@last_shell_command_status = nil
|
103
|
+
|
104
|
+
machine.communicate.tap do |comm|
|
105
|
+
|
106
|
+
@last_shell_command_status = comm.execute(
|
107
|
+
command, {
|
108
|
+
:error_check => false,
|
109
|
+
:sudo => opts[:as_root]
|
110
|
+
}
|
111
|
+
) do |type,data|
|
112
|
+
|
113
|
+
if @vagrant_cucumber_debug
|
114
|
+
puts "[:#{type}] #{data.chomp}"
|
115
|
+
end
|
116
|
+
|
117
|
+
@last_shell_command_output[type] += data
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
if opts[:expect_nonzero]
|
124
|
+
|
125
|
+
if @last_shell_command_status != 0
|
126
|
+
raise "Expected command to return non-zero, got #{@last_shell_command_status}"
|
127
|
+
end
|
128
|
+
|
129
|
+
elsif opts.has_key?(:expect)
|
130
|
+
|
131
|
+
if @last_shell_command_status != opts[:expect]
|
132
|
+
raise "Expected command to return #{opts[:expect]}, got #{@last_shell_command_status}"
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
91
139
|
end
|
92
140
|
|
93
141
|
|
@@ -21,52 +21,40 @@ end
|
|
21
21
|
|
22
22
|
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})(?:|, it) should (succeed|fail)$/ do |command,as_root,vmre,condition|
|
23
23
|
|
24
|
-
|
25
|
-
:
|
26
|
-
:
|
27
|
-
}
|
28
|
-
|
29
|
-
@last_shell_command_status = nil
|
30
|
-
|
31
|
-
machine = vagrant_glue.identified_vm(vmre)
|
32
|
-
machine.communicate.tap do |comm|
|
24
|
+
options = {
|
25
|
+
:as_root => ( as_root == ' as root' ),
|
26
|
+
:expect_non_zero => ( condition == 'fail' ),
|
27
|
+
}
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:sudo => as_root == ' as root',
|
38
|
-
}
|
39
|
-
) do |type,data|
|
29
|
+
if condition == 'succeed'
|
30
|
+
options[:expect] = 0
|
31
|
+
end
|
40
32
|
|
41
|
-
|
42
|
-
puts "[:#{type}] #{data.chomp}"
|
43
|
-
end
|
33
|
+
vagrant_glue.execute_on_vm( command, vagrant_glue.identified_vm(vmre), options )
|
44
34
|
|
45
|
-
|
35
|
+
end
|
46
36
|
|
47
|
-
|
37
|
+
Then /^(?:running|I run) the shell command `(.*)`(| as root)(#{VMRE})$/ do |command,as_root,vmre|
|
48
38
|
|
49
|
-
|
39
|
+
options = {
|
40
|
+
:machine => vagrant_glue.identified_vm(vmre),
|
41
|
+
:as_root => ( as_root == ' as root' ),
|
42
|
+
}
|
50
43
|
|
51
|
-
|
52
|
-
raise "Expected command to fail, but got 0 exit status"
|
53
|
-
end
|
54
|
-
|
55
|
-
if @last_shell_command_status != 0 and condition == 'succeed'
|
56
|
-
raise "Expected command to succeed but got #{@last_shell_command_status} exit status"
|
57
|
-
end
|
44
|
+
vagrant_glue.execute_on_vm( command, vagrant_glue.identified_vm(vmre), options )
|
58
45
|
|
59
46
|
end
|
60
47
|
|
48
|
+
|
61
49
|
Then /^the (.+) of that shell command should(| not) match (\/.+\/)$/ do |stream,condition,re|
|
62
50
|
|
63
51
|
stream.downcase!
|
64
52
|
|
65
|
-
unless
|
66
|
-
raise "
|
53
|
+
unless vagrant_glue.last_shell_command_output.has_key?( stream.to_sym )
|
54
|
+
raise "vagrant_glue.last_shell_command_output structure has no #{stream}"
|
67
55
|
end
|
68
56
|
|
69
|
-
re_result = (
|
57
|
+
re_result = ( vagrant_glue.last_shell_command_output[stream.to_sym] =~ re.to_regexp )
|
70
58
|
re_matched = !re_result.nil?
|
71
59
|
|
72
60
|
should_match = condition != ' not'
|
data/vagrant-cucumber.gemspec
CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/scalefactory/vagrant-cucumber"
|
11
11
|
s.summary = %q{Cucumber support for Vagrant}
|
12
12
|
s.description = %q{This plugin makes it possible for Cucumber to interact with Vagrant}
|
13
|
+
s.license = 'MIT'
|
13
14
|
|
14
15
|
s.rubyforge_project = "vagrant-cucumber"
|
15
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
16
|
-
requirement: &
|
16
|
+
requirement: &70291725096880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70291725096880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vagrant-multiprovider-snap
|
27
|
-
requirement: &
|
27
|
+
requirement: &70291725111160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.0.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70291725111160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: to_regexp
|
38
|
-
requirement: &
|
38
|
+
requirement: &70291725109880 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.2.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70291725109880
|
47
47
|
description: This plugin makes it possible for Cucumber to interact with Vagrant
|
48
48
|
email:
|
49
49
|
- jon@scalefactory.com
|
@@ -52,6 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- CHANGELOG.md
|
55
|
+
- CONTRIBUTING.md
|
55
56
|
- LICENSE
|
56
57
|
- README.md
|
57
58
|
- example/Vagrantfile
|
@@ -70,7 +71,8 @@ files:
|
|
70
71
|
- lib/vagrant-cucumber/version.rb
|
71
72
|
- vagrant-cucumber.gemspec
|
72
73
|
homepage: https://github.com/scalefactory/vagrant-cucumber
|
73
|
-
licenses:
|
74
|
+
licenses:
|
75
|
+
- MIT
|
74
76
|
post_install_message:
|
75
77
|
rdoc_options: []
|
76
78
|
require_paths:
|