guard-rake-vagrant 0.0.2 → 0.0.3

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjdlNDEzMmY1ZGIyZGYxZmVmNTMyMDZmYjc1YTAyZDRkY2I5YmZhNg==
5
+ data.tar.gz: !binary |-
6
+ OTA1NGU2M2Y2YmM3ZDgwNDg5Nzk4MGQzN2U2ZDRkNTA1OWMxODJhYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTMzOTRkYzdjZTdiMDRkNDA3NDVjMDYwYmViZjNlM2E5ZTlmZjIzZjgzYWIz
10
+ ZmFiZGU1ZmIyYmQ2NTlmYjYzYmM1NWNhYjNhYzA0MTcyYjBkZDljZTY2NGVk
11
+ YjhmN2Q4OTk2NmI4ZDA2Mzc0OWMzMzIxNWFhMWVjODA3MzE4YTM=
12
+ data.tar.gz: !binary |-
13
+ NjVjODYwODg0NTNmMmZlMzYzMzcyMmE4NGRmNzJjNjE1ZDVjODc0OGQ4NTZj
14
+ MjRkYTBhZDM5OWFmYzU0ZDZjMThhYWJjZjkyZjIwNzMwMTE2Nzg3NmJmMDg0
15
+ ZmUxYzcxOGFjOGM2ZmRmMzA2N2ZlMTk3OGYyN2E2YzY5NTlkZmQ=
data/Gemfile CHANGED
@@ -1,5 +1,13 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rake'
4
-
5
3
  gemspec
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem "ruby_gntp"
10
+ gem 'rb-inotify', :require => false
11
+ gem 'rb-fsevent', :require => false
12
+ gem 'rb-fchange', :require => false
13
+ end
data/README.md CHANGED
@@ -1,64 +1,97 @@
1
- guard-rake-vagrant
2
- ==================
3
-
4
- Guard Plugin that uses Rake and Vagrant to converge cookbooks and run integration tests.
5
-
6
- Software & Tools
7
- ------------
8
-
9
- This gem depends on the well installation of the following software & tools:
10
- * Vagrant - Recomended version 1.2.2 - http://downloads.vagrantup.com/tags/v1.2.2
11
- * Vagrant Plugins
12
- * vagrant-berkshelf (1.3.7)
13
- * vagrant-windows (1.5.1)
14
- ```
15
- # vagrant plugin install vagrant-berkshelf
16
- # vagrant plugin install vagrant-windows
17
- ```
18
-
19
- Installation
20
- ------------
21
-
22
- Add this line to your application's Gemfile:
23
-
24
- gem 'guard-rake-vagrant'
25
-
26
- And then execute:
27
-
28
- $ bundle install
29
-
30
- Or install it yourself as:
31
-
32
- $ gem install guard-rake-vagrant
33
-
34
- Setup
35
- ------------
36
-
37
- Create a Guardfile:
38
- ```
39
- guard :rake, :task => 'doit' do
40
- watch(%r{^test/.+_spec\.rb$})
41
- end
42
- ```
43
-
44
- Create a Rakefile:
45
- ```
46
- require 'rake'
47
- require 'rspec/core/rake_task'
48
-
49
- RSpec::Core::RakeTask.new(:doit) do |t|
50
- # actions (may reference t)
51
- end
52
-
53
- desc "This is the description of my :doit task "
54
- ```
55
-
56
- And then execute:
57
-
58
- $ bundle exec guard
59
-
60
-
61
- Authors
62
- ------------
63
- Created and maintained by [Salim Afiune](https://github.com/afiune) (salim@afiunemaya.com.mx) and the community.
64
-
1
+ guard-rake-vagrant
2
+ ==================
3
+
4
+ Guard Plugin that uses Rake and Vagrant to converge Chef Cookbooks and run integration tests.
5
+
6
+ Software & Tools
7
+ ------------
8
+
9
+ This gem depends on the well installation of the following software & tools:
10
+ * Vagrant - Recomended version 1.2.2 - http://downloads.vagrantup.com/tags/v1.2.2
11
+ * Vagrant Plugins
12
+ * vagrant-berkshelf (1.3.7)
13
+ * vagrant-windows (1.5.1)
14
+ ```
15
+ # vagrant plugin install vagrant-berkshelf
16
+ # vagrant plugin install vagrant-windows
17
+ ```
18
+
19
+ Installation
20
+ ------------
21
+
22
+ Add this line to your Cookbook Gemfile:
23
+
24
+ gem 'guard-rake-vagrant'
25
+
26
+ And then execute:
27
+
28
+ $ bundle install
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install guard-rake-vagrant
33
+
34
+ Setup
35
+ ------------
36
+
37
+ Create a Guardfile:
38
+ ```
39
+ guard :rake, :task => 'doit' do
40
+ watch(%r{^test/.+_spec\.rb$})
41
+ end
42
+ ```
43
+
44
+ Create a Rakefile:
45
+ ```
46
+ require 'rake'
47
+ require 'rspec/core/rake_task'
48
+
49
+ RSpec::Core::RakeTask.new(:doit) do |t|
50
+ # actions (may reference t)
51
+ end
52
+
53
+ desc "This is the description of my :doit task "
54
+ ```
55
+
56
+ Create a Vagrantfile:
57
+ ```
58
+ box = "Windows2008R2"
59
+ box_url = "Windows2008R2.box"
60
+ cookbook_name = "my_cookbook_name"
61
+
62
+ Vagrant.configure("2") do |config|
63
+ config.vm.define cookbook_name do |config|
64
+ config.vm.box = box
65
+ config.vm.box_url = box_url
66
+
67
+ # Windows Plugin if platform?("windows")
68
+ config.vm.guest = :windows
69
+
70
+ # FW ports if platform?("windows")
71
+ config.vm.network :forwarded_port, { :guest=>3389, :host=>3389, :id=>"rdp", :auto_correct=>true }
72
+ config.vm.network :forwarded_port, { :guest=>5985, :host=>5985, :id=>"winrm", :auto_correct=>true }
73
+
74
+ # Berkshelf Plugin
75
+ config.berkshelf.enabled = true
76
+
77
+ config.vm.provider :virtualbox do |p|
78
+ p.customize ["modifyvm", :id, "--memory", "512"]
79
+ end
80
+
81
+ config.vm.provision :chef_solo do |chef|
82
+ chef.log_level = :auto
83
+ chef.run_list = ["recipe[" + cookbook_name + "]"]
84
+ end
85
+ end
86
+ end
87
+ ```
88
+
89
+ And then execute:
90
+
91
+ $ bundle exec guard
92
+
93
+
94
+ Authors
95
+ ------------
96
+ Created and maintained by [Salim Afiune](https://github.com/afiune) (salim@afiunemaya.com.mx) and the community.
97
+
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.add_dependency 'guard'
15
15
  s.add_dependency 'rake'
16
+ s.add_dependency 'mixlib-shellout'
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -42,6 +42,7 @@ module Guard
42
42
  end
43
43
 
44
44
  def run_all
45
+ ::Guard::Rake::Vagrant.provision
45
46
  run_rake_task if @options[:run_on_all]
46
47
  end
47
48
 
@@ -1,64 +1,64 @@
1
- require 'guard'
2
- require 'guard/guard'
3
- require "mixlib/shellout"
4
-
5
- module Guard
6
- class Rake
7
- class Vagrant
8
- class << self
9
- def up
10
- UI.info "Guard::Rake::Vagrant box is starting"
11
- cmd = Mixlib::ShellOut.new("vagrant up", :timeout => 10800)
12
- cmd.live_stream = STDOUT
13
- cmd.run_command
14
-
15
- begin
16
- cmd.error!
17
- Notifier.notify('Vagrant box created', :title => 'guard-rake-vagrant', :image => :success)
18
- rescue Mixlib::ShellOut::ShellCommandFailed => e
19
- Notifier.notify('Vagrant box create failed', :title => 'guard-rake-vagrant', :image => :failed)
20
- ::Guard::UI.info("Vagrant box failed with #{e.to_s}")
21
- throw :task_has_failed
22
- end
23
- end
24
-
25
- def destroy
26
- ::Guard::UI.info("Guard::Rake::Vagrant box is stopping")
27
- cmd = Mixlib::ShellOut.new("vagrant destroy -f")
28
- cmd.live_stream = STDOUT
29
- cmd.run_command
30
- begin
31
- cmd.error!
32
- rescue Mixlib::ShellOut::ShellCommandFailed => e
33
- ::Guard::UI.info("Vagrant box failed #{e.to_s}")
34
- throw :task_has_failed
35
- ensure
36
- # Sometimes, we leave the occasional shell process unreaped!
37
- Process.waitall
38
- end
39
- end
40
-
41
- def provision
42
- UI.info "Guard::Rake::Vagrant box is provisioning"
43
- cmd = Mixlib::ShellOut.new("vagrant provision", :timeout => 10800)
44
- cmd.live_stream = STDOUT
45
- cmd.run_command
46
-
47
- begin
48
- cmd.error!
49
- Notifier.notify('Vagrant box provisioned', :title => 'guard-vagrant', :image => :success)
50
- rescue Mixlib::ShellOut::ShellCommandFailed => e
51
- Notifier.notify('Vagrant box provision failed', :title => 'guard-vagrant', :image => :failed)
52
- ::Guard::UI.info("Vagrant box provision failed with #{e.to_s}")
53
- throw :task_has_failed
54
- end
55
-
56
- if cmd.stdout =~ /VM is not currently running/
57
- UI.info "Guard::Rake::Vagrant box is not running"
58
- self.up
59
- end
60
- end
61
- end
62
- end
63
- end
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require "mixlib/shellout"
4
+
5
+ module Guard
6
+ class Rake
7
+ class Vagrant
8
+ class << self
9
+ def up
10
+ UI.info "Guard::Rake::Vagrant box is starting"
11
+ cmd = Mixlib::ShellOut.new("vagrant up", :timeout => 10800)
12
+ cmd.live_stream = STDOUT
13
+ cmd.run_command
14
+
15
+ begin
16
+ cmd.error!
17
+ Notifier.notify('Vagrant box created', :title => 'guard-rake-vagrant', :image => :success)
18
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
19
+ Notifier.notify('Vagrant box create failed', :title => 'guard-rake-vagrant', :image => :failed)
20
+ UI.info("Vagrant box failed with #{e.to_s}")
21
+ throw :task_has_failed
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ UI.info("Guard::Rake::Vagrant box is stopping")
27
+ cmd = Mixlib::ShellOut.new("vagrant destroy -f", :timeout => 300)
28
+ cmd.live_stream = STDOUT
29
+ cmd.run_command
30
+
31
+ begin
32
+ cmd.error!
33
+ Notifier.notify('Vagrant box destroyed', :title => 'guard-rake-vagrant', :image => :success)
34
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
35
+ Notifier.notify('Vagrant box destroy failed', :title => 'guard-rake-vagrant', :image => :failed)
36
+ UI.info("Vagrant box failed #{e.to_s}")
37
+ throw :task_has_failed
38
+ end
39
+ end
40
+
41
+ def provision
42
+ UI.info "Guard::Rake::Vagrant box is provisioning"
43
+ cmd = Mixlib::ShellOut.new("vagrant provision", :timeout => 10800)
44
+ cmd.live_stream = STDOUT
45
+ cmd.run_command
46
+
47
+ begin
48
+ cmd.error!
49
+ Notifier.notify('Vagrant box provisioned', :title => 'guard-vagrant', :image => :success)
50
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
51
+ Notifier.notify('Vagrant box provision failed', :title => 'guard-vagrant', :image => :failed)
52
+ UI.info("Vagrant box provision failed with #{e.to_s}")
53
+ throw :task_has_failed
54
+ end
55
+
56
+ if cmd.stdout =~ /VM is not currently running/
57
+ UI.info "Guard::Rake::Vagrant box is not running"
58
+ self.up
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
64
  end
@@ -1,7 +1,7 @@
1
1
  module Guard
2
2
  module Rake
3
3
  module Vagrant
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+
3
+ $: << File.expand_path(File.dirname(__FILE__))
4
+
5
+ RSpec.configure do |c|
6
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+ require 'guard/rake'
3
+
4
+ describe "Guard::Rake" do
5
+ let(:rake) do
6
+ Guard::Rake.new
7
+ end
8
+
9
+ describe "start" do
10
+ before(:each) do
11
+ @shellout = double('shellout')
12
+ @shellout.stub(:live_stream=).with(STDOUT)
13
+ @shellout.stub(:run_command)
14
+ @shellout.stub(:error!)
15
+ Guard::UI.stub(:info).with('Guard::Rake::Vagrant box is starting')
16
+ Guard::UI.stub(:info).with('Starting guard-rake-vagrant')
17
+ Mixlib::ShellOut.stub(:new).with("vagrant up").and_return(@shellout)
18
+ end
19
+
20
+ it "runs vagrant up" do
21
+ Mixlib::ShellOut.should_receive(:new).with("vagrant up").and_return(@shellout)
22
+ Guard::UI.should_receive(:info).with('Guard::Rake::Vagrant box is starting')
23
+ Guard::Notifier.should_receive(:notify).with('Vagrant box created', :title => 'guard-rake-vagrant', :image => :success)
24
+ rake.start
25
+ end
26
+
27
+ it "notifies on failure" do
28
+ @shellout.should_receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
29
+ Guard::UI.should_receive(:info).with('Guard::Rake::Vagrant box is starting')
30
+ Guard::Notifier.should_receive(:notify).with('Vagrant box create failed', :title => 'guard-rake-vagrant', :image => :failed)
31
+ Guard::UI.should_receive(:info).with('Vagrant box failed with Mixlib::ShellOut::ShellCommandFailed')
32
+ expect { rake.start }.to throw_symbol(:task_has_failed)
33
+ end
34
+ end
35
+ describe "reload" do
36
+ it "calls stop and start" do
37
+ rake.should_receive(:stop)
38
+ rake.should_receive(:start)
39
+ rake.reload
40
+ end
41
+ end
42
+
43
+ describe "stop" do
44
+ before(:each) do
45
+ @shellout = double('shellout')
46
+ @shellout.stub(:live_stream=).with(STDOUT)
47
+ @shellout.stub(:run_command)
48
+ @shellout.stub(:error!)
49
+ Guard::UI.stub(:info).with('Guard::Rake::Vagrant box is stopping')
50
+ Guard::UI.stub(:info).with('Stopping guard-rake-vagrant')
51
+ Mixlib::ShellOut.stub(:new).with("vagrant destroy -f").and_return(@shellout)
52
+ end
53
+ it "runs vagrant destroy -f" do
54
+ Mixlib::ShellOut.should_receive(:new).with("vagrant destroy -f").and_return(@shellout)
55
+ Guard::UI.should_receive(:info).with('Guard::Rake::Vagrant box is stopping')
56
+ Guard::Notifier.should_receive(:notify).with('Vagrant box destroyed', :title => 'guard-rake-vagrant', :image => :success)
57
+ rake.stop
58
+ end
59
+
60
+ it "notifies on failure" do
61
+ @shellout.should_receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
62
+ Guard::UI.should_receive(:info).with('Guard::Rake::Vagrant box is stopping')
63
+ Guard::Notifier.should_receive(:notify).with('Vagrant box destroy failed', :title => 'guard-rake-vagrant', :image => :failed)
64
+ Guard::UI.should_receive(:info).with('Vagrant box failed with Mixlib::ShellOut::ShellCommandFailed')
65
+ expect { rake.stop }.to throw_symbol(:task_has_failed)
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rake-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Salim Afiune
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-21 00:00:00.000000000 Z
11
+ date: 2014-03-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: guard
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,20 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mixlib-shellout
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
42
51
  requirements:
43
52
  - - ! '>='
44
53
  - !ruby/object:Gem::Version
@@ -61,29 +70,32 @@ files:
61
70
  - lib/guard/rake/templates/Guardfile
62
71
  - lib/guard/rake/vagrant.rb
63
72
  - lib/guard/rake/version.rb
73
+ - spec/spec_helper.rb
74
+ - spec/unit/guard/rake_spec.rb
64
75
  homepage: https://github.com/afiune/guard-rake-vagrant
65
76
  licenses: []
77
+ metadata: {}
66
78
  post_install_message:
67
79
  rdoc_options: []
68
80
  require_paths:
69
81
  - lib
70
82
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
83
  requirements:
73
84
  - - ! '>='
74
85
  - !ruby/object:Gem::Version
75
86
  version: '0'
76
87
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
88
  requirements:
79
89
  - - ! '>='
80
90
  - !ruby/object:Gem::Version
81
91
  version: '0'
82
92
  requirements: []
83
93
  rubyforge_project:
84
- rubygems_version: 1.8.24
94
+ rubygems_version: 2.2.2
85
95
  signing_key:
86
- specification_version: 3
96
+ specification_version: 4
87
97
  summary: Guard Plugin that uses Rake and Vagrant to converge cookbooks and run integration
88
98
  tests
89
- test_files: []
99
+ test_files:
100
+ - spec/spec_helper.rb
101
+ - spec/unit/guard/rake_spec.rb