blimpy-cucumber 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blimpy-cucumber.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+ gem 'blimpy', :path => '../blimpy'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 R. Tyler Croy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Blimpy for Cucumber
2
+
3
+
4
+ This gem helps incorporate [Blimpy](https://github.com/rtyler/blimpy) with [Cucumber](http://cukes.info) for
5
+ integration testing with a VM running on any cloud that Blimpy supports.
6
+
7
+ ## Contributing
8
+
9
+ 1. Fork it
10
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
11
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
12
+ 4. Push to the branch (`git push origin my-new-feature`)
13
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/blimpy/cucumber/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["R. Tyler Croy"]
6
+ gem.email = ["tyler@monkeypox.org"]
7
+ gem.description = "Cucumber steps for testing with Blimpy"
8
+ gem.summary = "This gem helps spin up and down VMs with Blimpy from within Cucumber tests"
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "blimpy-cucumber"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Blimpy::Cucumber::VERSION
17
+
18
+ gem.add_dependency('blimpy', '~> 0.6.0')
19
+ end
@@ -0,0 +1,112 @@
1
+ require 'fileutils'
2
+ require 'rubygems'
3
+ require 'blimpy'
4
+
5
+
6
+ module Blimpy
7
+ module Cucumber
8
+ module API
9
+ def start_vms
10
+ # Make sure we set up our vms at some point properly
11
+ expect(vm).to_not be_nil
12
+ @fleet.start
13
+ end
14
+
15
+ def destroy_vms
16
+ @fleet.destroy unless @fleet.nil?
17
+ end
18
+
19
+ def vm_name
20
+ # If @vmname exists, we'll use that
21
+ return @vmname unless @vmname.nil?
22
+ 'blimpy-cucumber-test'
23
+ end
24
+
25
+ def vm_flavor
26
+ return @vmflavor unless @vmflavor.nil?
27
+ 'm1.small'
28
+ end
29
+
30
+ def vm_ports
31
+ return @vmports unless @vmports.nil?
32
+ [22, 80, 8080]
33
+ end
34
+
35
+ def vm(type='Linux')
36
+ unless @fleet.nil?
37
+ return @fleet.ships.first
38
+ end
39
+
40
+ # Default to Ubuntu 12.04 LTS in us-west-2
41
+ image_id = 'ami-4038b470'
42
+ region = 'us-west-2'
43
+ username = 'ubuntu'
44
+
45
+ if type == 'FreeBSD'
46
+ # FreeBSD 9.0-RELEASE/amd64 in us-west-2
47
+ image_id = 'ami-cab73afa'
48
+ username = 'root'
49
+ end
50
+
51
+ @fleet = Blimpy.fleet do |fleet|
52
+ fleet.add(:aws) do |ship|
53
+ ship.name = vm_name
54
+ ship.flavor = vm_flavor
55
+ ship.image_id = image_id
56
+ ship.username = username
57
+ ship.ports = vm_ports
58
+ ship.region = region
59
+ ship.livery = Blimpy::Livery::Puppet
60
+ end
61
+ end
62
+ @fleet.ships.first
63
+ end
64
+
65
+ def resources
66
+ # Resources should be an Array of strings that will be joined together to
67
+ # make the full Puppet node manifest that will be provisioned on the host
68
+ @resources ||= []
69
+ end
70
+
71
+ def work_dir
72
+ File.expand_path(File.dirname(__FILE__) + "/../../tmp/cucumber")
73
+ end
74
+
75
+ def manifest_path
76
+ File.join(work_dir, 'manifests')
77
+ end
78
+
79
+ def modules_path
80
+ File.join(work_dir, 'modules')
81
+ end
82
+
83
+ def setup_work_dir
84
+ # We can't set this up unless we've already "remembered" our original
85
+ # directory
86
+ expect(@original_dir).to_not be_nil
87
+
88
+ FileUtils.mkdir_p(manifest_path)
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ Before do
95
+ @original_dir = Dir.pwd
96
+
97
+ unless File.exists?(work_dir)
98
+ FileUtils.mkdir_p(work_dir)
99
+ end
100
+
101
+ Dir.chdir(work_dir)
102
+
103
+ setup_work_dir
104
+ end
105
+
106
+ After do
107
+ destroy_vms
108
+
109
+ Dir.chdir(@original_dir)
110
+ # Nuke the temporary working directory after we're all finished
111
+ FileUtils.rm_rf(work_dir)
112
+ end
@@ -0,0 +1,5 @@
1
+ module Blimpy
2
+ module Cucumber
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'blimpy/cucumber/api'
3
+
4
+
5
+ World(Blimpy::Cucumber::API)
6
+
7
+ Given /^I have an empty (.*?) machine$/ do |type|
8
+ expect(vm(type)).to_not be_nil
9
+ end
10
+
11
+ When /^I provision the host$/ do
12
+ resources << "group { 'puppet' : ensure => present; }"
13
+
14
+ File.open(File.join(manifest_path, 'site.pp'), 'w') do |f|
15
+ f.write("node default {\n")
16
+ resources.each do |r|
17
+ f.write("#{r}\n")
18
+ end
19
+ f.write("}\n")
20
+ end
21
+
22
+ start_vms
23
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blimpy-cucumber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - R. Tyler Croy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-03 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: blimpy
16
+ requirement: &18197180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *18197180
25
+ description: Cucumber steps for testing with Blimpy
26
+ email:
27
+ - tyler@monkeypox.org
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - blimpy-cucumber.gemspec
38
+ - lib/blimpy/cucumber.rb
39
+ - lib/blimpy/cucumber/api.rb
40
+ - lib/blimpy/cucumber/version.rb
41
+ homepage: ''
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ segments:
54
+ - 0
55
+ hash: -1288873399811591327
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ segments:
63
+ - 0
64
+ hash: -1288873399811591327
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.10
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: This gem helps spin up and down VMs with Blimpy from within Cucumber tests
71
+ test_files: []