foodtaster 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/foodtaster.gemspec +1 -1
- data/lib/foodtaster/client.rb +3 -2
- data/lib/foodtaster/rspec/dsl_methods.rb +3 -6
- data/lib/foodtaster/rspec/example_methods.rb +6 -3
- data/lib/foodtaster/rspec/matchers/service_matcher.rb +18 -0
- data/lib/foodtaster/rspec/matchers/simple_matchers.rb +3 -4
- data/lib/foodtaster/version.rb +1 -1
- data/lib/foodtaster/vm.rb +12 -0
- metadata +4 -2
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Foodtæster
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/foodtaster.png)](http://badge.fury.io/rb/foodtaster)
|
4
|
+
|
3
5
|
Foodtaster is a library for testing your Chef code with RSpec. Specs
|
4
6
|
are actually executed on VirtualBox machine(s) managed by
|
5
7
|
[Vagrant](http://www.vagrantup.com/).
|
@@ -96,8 +98,22 @@ You are ready to write cookbook specs. Run them as usual with command:
|
|
96
98
|
|
97
99
|
bundle exec rspec spec
|
98
100
|
|
101
|
+
## Roadmap
|
102
|
+
|
103
|
+
- foodtaster-example-single-cookbook repo
|
104
|
+
- tests/specs
|
105
|
+
- documentation
|
106
|
+
- comments in code
|
107
|
+
- inline sahara plugin into vagrant-foodtaster-server
|
108
|
+
- Capistrno support or just an example
|
109
|
+
- Puppet support
|
110
|
+
- LXC support
|
111
|
+
|
99
112
|
## Contributing
|
100
113
|
|
114
|
+
If you found a bug or you wish to implement something from Roadmap,
|
115
|
+
use this workflow:
|
116
|
+
|
101
117
|
1. Fork it
|
102
118
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
103
119
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
data/foodtaster.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'foodtaster/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "foodtaster"
|
8
8
|
gem.version = Foodtaster::VERSION
|
9
|
-
gem.authors = ["Mike Lapshin"]
|
9
|
+
gem.authors = ["Mike Lapshin", "Serzh Nechyporchuk"]
|
10
10
|
gem.email = ["mikhail.a.lapshin@gmail.com"]
|
11
11
|
gem.description = %q{RSpec for Chef cookbooks run on Vagrant}
|
12
12
|
gem.summary = %q{Foodtaster is a library for testing your Chef code with RSpec.}
|
data/lib/foodtaster/client.rb
CHANGED
@@ -25,10 +25,11 @@ module Foodtaster
|
|
25
25
|
client
|
26
26
|
end
|
27
27
|
|
28
|
-
[:vm_defined?, :
|
28
|
+
[:vm_defined?, :rollback_vm,
|
29
29
|
:run_chef_on_vm, :execute_command_on_vm,
|
30
30
|
:shutdown_vm, :vm_running?, :initial_snapshot_made_on_vm?,
|
31
|
-
:start_vm, :make_initial_snapshot_on_vm
|
31
|
+
:start_vm, :make_initial_snapshot_on_vm, :vm_ip,
|
32
|
+
:put_file_to_vm, :get_file_from_vm].each do |method_name|
|
32
33
|
define_method method_name do |*args|
|
33
34
|
begin
|
34
35
|
@v.send(method_name, *args)
|
@@ -2,20 +2,17 @@ module Foodtaster
|
|
2
2
|
module RSpec
|
3
3
|
module DslMethods
|
4
4
|
def require_vm(vm_name)
|
5
|
-
|
6
|
-
get_vm(vm_name)
|
7
|
-
end
|
8
|
-
|
5
|
+
define_method(vm_name) { get_vm(vm_name) }
|
9
6
|
before(:all) { get_vm(vm_name) }
|
10
7
|
end
|
11
8
|
|
12
9
|
def run_chef_on(vm_name, options = {}, &block)
|
13
10
|
require_vm(vm_name)
|
14
|
-
|
11
|
+
rollback = options.key?(:rollback) ? options[:rollback] : !Foodtaster.config.skip_rollback
|
15
12
|
|
16
13
|
before(:all) do
|
17
14
|
vm = get_vm(vm_name)
|
18
|
-
vm.rollback
|
15
|
+
vm.rollback if rollback
|
19
16
|
|
20
17
|
run_chef_on(vm_name, &block)
|
21
18
|
end
|
@@ -8,11 +8,14 @@ module Foodtaster
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run_chef_on(vm_name, &block)
|
11
|
-
chef_config = ChefConfig.new
|
12
|
-
|
11
|
+
chef_config = ChefConfig.new
|
12
|
+
instance_exec chef_config, &block
|
13
|
+
chef_config_as_hash = chef_config.to_hash
|
14
|
+
|
15
|
+
@previous_chef_config = chef_config_as_hash
|
13
16
|
|
14
17
|
vm = get_vm(vm_name)
|
15
|
-
vm.run_chef(
|
18
|
+
vm.run_chef(chef_config_as_hash)
|
16
19
|
end
|
17
20
|
|
18
21
|
def rerun_chef_on(vm_name)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec::Matchers.define :have_running_service do |service|
|
2
|
+
match do |vm|
|
3
|
+
@result = vm.execute("status #{service}").stdout
|
4
|
+
@result =~ /start\/running/
|
5
|
+
end
|
6
|
+
|
7
|
+
failure_message_for_should do |vm|
|
8
|
+
"expected that #{vm.name} should have running service '#{service}' but was '#{@result}'"
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message_for_should_not do |vm|
|
12
|
+
"expected that #{vm.name} should not have running service '#{service}' but was '#{@result}'"
|
13
|
+
end
|
14
|
+
|
15
|
+
description do
|
16
|
+
"running service '#{service}'"
|
17
|
+
end
|
18
|
+
end
|
@@ -38,18 +38,17 @@ RSpec::Matchers.define :have_package do |package|
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
# TODO: I'm not sure if lsof is installed by default
|
42
41
|
RSpec::Matchers.define :listen_port do |port|
|
43
42
|
match do |vm|
|
44
|
-
|
43
|
+
vm.execute("lsof -i :#{port.to_s}").should be_successful
|
45
44
|
end
|
46
45
|
|
47
46
|
failure_message_for_should do |vm|
|
48
|
-
"expected that #{vm.name} should listen port '#{port}'"
|
47
|
+
"expected that #{vm.name} should listen to port '#{port}'"
|
49
48
|
end
|
50
49
|
|
51
50
|
failure_message_for_should_not do |vm|
|
52
|
-
"expected that #{vm.name} should not listen port '#{port}'"
|
51
|
+
"expected that #{vm.name} should not listen to port '#{port}'"
|
53
52
|
end
|
54
53
|
|
55
54
|
description do
|
data/lib/foodtaster/version.rb
CHANGED
data/lib/foodtaster/vm.rb
CHANGED
@@ -87,6 +87,18 @@ module Foodtaster
|
|
87
87
|
self.running? && self.initial_snapshot_made?
|
88
88
|
end
|
89
89
|
|
90
|
+
def ip
|
91
|
+
@client.vm_ip(name)
|
92
|
+
end
|
93
|
+
|
94
|
+
def put_file(local_fn, vm_fn)
|
95
|
+
@client.put_file_to_vm(name, local_fn, vm_fn)
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_file(vm_fn, local_fn)
|
99
|
+
@client.get_file_from_vm(name, vm_fn, local_fn)
|
100
|
+
end
|
101
|
+
|
90
102
|
def shutdown
|
91
103
|
Foodtaster.logger.debug "#{name}: Shutting down VM"
|
92
104
|
@client.shutdown_vm(name)
|
metadata
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
name: foodtaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Lapshin
|
9
|
+
- Serzh Nechyporchuk
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
prerelease: false
|
@@ -48,6 +49,7 @@ files:
|
|
48
49
|
- lib/foodtaster/rspec/dsl_methods.rb
|
49
50
|
- lib/foodtaster/rspec/example_methods.rb
|
50
51
|
- lib/foodtaster/rspec/matchers/file_matcher.rb
|
52
|
+
- lib/foodtaster/rspec/matchers/service_matcher.rb
|
51
53
|
- lib/foodtaster/rspec/matchers/simple_matchers.rb
|
52
54
|
- lib/foodtaster/rspec/matchers/user_matcher.rb
|
53
55
|
- lib/foodtaster/rspec_run.rb
|