butcher 0.0.3 → 0.0.4

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.
@@ -1 +1 @@
1
- 1.9.3-p125
1
+ 1.9.3-p194
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Butcher
2
2
 
3
+ [![Build status](https://secure.travis-ci.org/livinginthepast/butcher.png)](http://travis-ci.org/livinginthepast/butcher)
4
+
3
5
  Butcher is a set of command line tools intended to ease the use of Chef with a managed
4
6
  Opscode account.
5
7
 
@@ -49,11 +51,6 @@ by looking at the chef_server_url in your knife.rb. For this reason, stab can on
49
51
  from the top level of a chef repo.
50
52
 
51
53
 
52
- ## Build Status
53
-
54
- [![Build status](https://secure.travis-ci.org/modcloth/butcher.png)](http://travis-ci.org/modcloth/butcher)
55
-
56
-
57
54
  ## License
58
55
 
59
56
  Copyright 2012 ModCloth
@@ -21,9 +21,11 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_development_dependency "rspec", "> 2"
23
23
  s.add_development_dependency "aruba"
24
- s.add_development_dependency "aruba-doubles", "~>0.2.3"
24
+ s.add_development_dependency "aruba-doubles"
25
+ s.add_development_dependency "rb-fsevent", '~> 0.9.1'
25
26
  s.add_development_dependency "guard-rspec"
26
27
  s.add_development_dependency "guard-cucumber"
27
28
  s.add_development_dependency "mocha"
28
29
  # s.add_runtime_dependency "x"
30
+ s.add_runtime_dependency "chef", "~> 10.14"
29
31
  end
@@ -1,13 +1,12 @@
1
1
  Feature: Stab
2
2
 
3
3
  Background:
4
- # stubbing knife currently doesn't work, but tests pass anyways
5
- #Given I could run `knife status` with stdout:
6
- #"""
7
- #1 minute ago, app.node, app.domain, 1.1.1.1, os
8
- #"""
4
+ Given I double `knife status` with stdout:
5
+ """
6
+ 1 minute ago, app.node, app.domain, 1.1.1.1, os
7
+ """
9
8
  Given I have a knife configuration file
10
- And I could run `ssh 1.1.1.1` with stdout:
9
+ And I double `ssh 1.1.1.1` with stdout:
11
10
  """
12
11
  ssh yay!
13
12
  """
@@ -61,7 +60,8 @@ Feature: Stab
61
60
  | 1 minute ago | app.node | app.domain | 1.1.1.1 | os |
62
61
  When I run `stab app.node -c tmp/test -f -v`
63
62
  Then the output should contain "Creating cache file of nodes"
64
- #And the exit status should be 0 ## Butcher::Cache does not use stubbed knife
63
+ And the double `knife status` should have been run
64
+ And the exit status should be 0
65
65
 
66
66
  Scenario: User sees error message if no node matches given name
67
67
  Given I have the following chef nodes:
@@ -89,7 +89,7 @@ Feature: Stab
89
89
  Scenario: User can connect to server with given user name
90
90
  Given I have the following chef nodes:
91
91
  | 1 minute ago | app.node | app.domain | 1.1.1.1 | os |
92
- Given I could run `ssh 1.1.1.1 -l user` with stdout:
92
+ Given I double `ssh 1.1.1.1 -l user` with stdout:
93
93
  """
94
94
  user: I'm a computer!
95
95
  """
@@ -8,6 +8,8 @@ Given /I (don't|) ?have a knife configuration file/ do |expectation|
8
8
  Given a file named "#{ENV["PWD"]}/.chef/knife.rb" with:
9
9
  """
10
10
  chef_server_url "https://opscode.url/organizations/my_organization"
11
+ validation_key "my_organization.pem"
12
+ validation_client_name "my_organization-validator"
11
13
  """
12
14
  }
13
15
  end
@@ -1,4 +1,5 @@
1
1
  require 'singleton'
2
+ require 'chef/config'
2
3
 
3
4
  class Butcher::Cache
4
5
  include Singleton
@@ -39,7 +40,8 @@ class Butcher::Cache
39
40
 
40
41
  def organization
41
42
  raise Butcher::NoKnifeRB unless(File.exists?(knife_file))
42
- if m = File.read(knife_file).match(/chef_server_url\s+".+organizations\/([^\/"]+)"/)
43
+ Chef::Config.from_file(knife_file)
44
+ if m = Chef::Config[:chef_server_url].match(%r[.+/organizations\/([^\/"]+)])
43
45
  m[1]
44
46
  else
45
47
  raise Butcher::NoKnifeOrganization
@@ -51,8 +53,10 @@ class Butcher::Cache
51
53
  end
52
54
 
53
55
  def create_node_cachefile
54
- File.open(nodes_file, "w") do |file|
55
- file.puts %x[knife status]
56
+ with_safe_paths do
57
+ File.open(nodes_file, "w") do |file|
58
+ file.puts %x[knife status]
59
+ end
56
60
  end
57
61
  end
58
62
 
@@ -66,4 +70,15 @@ class Butcher::Cache
66
70
  block.call f
67
71
  end
68
72
  end
73
+
74
+ # RVM rewrites paths to ensure that it is first. This makes it impossible
75
+ # to use aruba in cucumber with any gem executables.
76
+ def with_safe_paths
77
+ original_path = (ENV["PATH"] || '').split(::File::PATH_SEPARATOR)
78
+ aruba_path = original_path.select { |x| x =~ /\/tmp\/d\d{8}-\d+-.+/}
79
+ ENV['PATH'] = (aruba_path | original_path).join(::File::PATH_SEPARATOR)
80
+ yield
81
+ ensure
82
+ ENV["PATH"] = original_path.join(::File::PATH_SEPARATOR)
83
+ end
69
84
  end
@@ -1,3 +1,3 @@
1
1
  module Butcher
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -32,13 +32,17 @@ describe Butcher::Cache, "#nodes_file" do
32
32
  end
33
33
 
34
34
  context "sees a knife.rb" do
35
- before { File.expects(:exists?).with("#{ENV["PWD"]}/.chef/knife.rb").returns(true) }
35
+ before {
36
+ File.expects(:exists?).with("#{ENV["PWD"]}/.chef/knife.rb").returns(true)
37
+ Chef::Config.expects(:from_file).with("#{ENV["PWD"]}/.chef/knife.rb").returns(true)
38
+ }
36
39
 
37
40
  context "without chef_server_url" do
41
+ before {
42
+ Chef::Config.expects(:[]).with(:chef_server_url).returns("random content")
43
+ }
44
+
38
45
  it "should raise an error" do
39
- File.expects(:read).with("#{ENV["PWD"]}/.chef/knife.rb").returns(
40
- 'some random content'
41
- )
42
46
  lambda {
43
47
  Butcher::Cache.instance.nodes_file
44
48
  }.should raise_error(Butcher::NoKnifeOrganization)
@@ -47,11 +51,11 @@ describe Butcher::Cache, "#nodes_file" do
47
51
 
48
52
  context "with chef_server_url" do
49
53
  let(:expected_file) { "#{Butcher::TestCache.cache_dir}/my_organization.cache" }
54
+ before {
55
+ Chef::Config.expects(:[]).with(:chef_server_url).returns("https://api.opscode.com/organizations/my_organization")
56
+ }
50
57
 
51
58
  it "should set filename based on chef_server_url" do
52
- File.expects(:read).with("#{ENV["PWD"]}/.chef/knife.rb").returns(
53
- 'chef_server_url "https://api.opscode.com/organizations/my_organization"'
54
- )
55
59
  Butcher::Cache.instance.nodes_file.should == expected_file
56
60
  end
57
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: butcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-23 00:00:00.000000000 Z
13
+ date: 2012-10-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70365541610940 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>'
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: '2'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70365541610940
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>'
29
+ - !ruby/object:Gem::Version
30
+ version: '2'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: aruba
28
- requirement: &70365541610520 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
@@ -33,21 +38,47 @@ dependencies:
33
38
  version: '0'
34
39
  type: :development
35
40
  prerelease: false
36
- version_requirements: *70365541610520
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: aruba-doubles
39
- requirement: &70365541609980 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rb-fsevent
65
+ requirement: !ruby/object:Gem::Requirement
40
66
  none: false
41
67
  requirements:
42
68
  - - ~>
43
69
  - !ruby/object:Gem::Version
44
- version: 0.2.3
70
+ version: 0.9.1
45
71
  type: :development
46
72
  prerelease: false
47
- version_requirements: *70365541609980
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 0.9.1
48
79
  - !ruby/object:Gem::Dependency
49
80
  name: guard-rspec
50
- requirement: &70365541609560 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
51
82
  none: false
52
83
  requirements:
53
84
  - - ! '>='
@@ -55,10 +86,15 @@ dependencies:
55
86
  version: '0'
56
87
  type: :development
57
88
  prerelease: false
58
- version_requirements: *70365541609560
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
59
95
  - !ruby/object:Gem::Dependency
60
96
  name: guard-cucumber
61
- requirement: &70365541609100 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
62
98
  none: false
63
99
  requirements:
64
100
  - - ! '>='
@@ -66,10 +102,15 @@ dependencies:
66
102
  version: '0'
67
103
  type: :development
68
104
  prerelease: false
69
- version_requirements: *70365541609100
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
70
111
  - !ruby/object:Gem::Dependency
71
112
  name: mocha
72
- requirement: &70365541608680 !ruby/object:Gem::Requirement
113
+ requirement: !ruby/object:Gem::Requirement
73
114
  none: false
74
115
  requirements:
75
116
  - - ! '>='
@@ -77,7 +118,28 @@ dependencies:
77
118
  version: '0'
78
119
  type: :development
79
120
  prerelease: false
80
- version_requirements: *70365541608680
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ - !ruby/object:Gem::Dependency
128
+ name: chef
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ~>
133
+ - !ruby/object:Gem::Version
134
+ version: '10.14'
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ~>
141
+ - !ruby/object:Gem::Version
142
+ version: '10.14'
81
143
  description: Chef is a tool for managing server automation. A good butcher makes for
82
144
  a good chef.
83
145
  email:
@@ -132,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
194
  version: '0'
133
195
  requirements: []
134
196
  rubyforge_project: butcher
135
- rubygems_version: 1.8.17
197
+ rubygems_version: 1.8.24
136
198
  signing_key:
137
199
  specification_version: 3
138
200
  summary: All the things to make a chef
@@ -147,3 +209,4 @@ test_files:
147
209
  - spec/lib/stab/cli_spec.rb
148
210
  - spec/spec_helper.rb
149
211
  - spec/support/test_cache.rb
212
+ has_rdoc: