serverspec 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,11 +6,15 @@ task :spec => 'spec:all'
6
6
  namespace :spec do
7
7
  oses = %w( darwin debian gentoo redhat solaris )
8
8
 
9
- task :all => oses.map {|os| "spec:#{os}" }
9
+ task :all => [ oses.map {|os| "spec:#{os}" }, :others].flatten
10
10
 
11
11
  oses.each do |os|
12
12
  RSpec::Core::RakeTask.new(os.to_sym) do |t|
13
13
  t.pattern = "spec/#{os}/*_spec.rb"
14
14
  end
15
15
  end
16
+
17
+ RSpec::Core::RakeTask.new(:others) do |t|
18
+ t.pattern = "spec/{helpers,backend}/*_spec.rb"
19
+ end
16
20
  end
@@ -25,6 +25,7 @@ RSpec.configure do |c|
25
25
  c.add_setting :host, :default => nil
26
26
  c.add_setting :ssh, :default => nil
27
27
  c.add_setting :sudo_password, :default => nil
28
+ c.add_setting :path, :default => nil
28
29
  c.before :each do
29
30
  if described_class.nil?
30
31
  puts
@@ -10,7 +10,7 @@ module Serverspec
10
10
  end
11
11
 
12
12
  def run_command(cmd, opts={})
13
- stdout = `PATH=/sbin:/usr/sbin:$PATH #{cmd} 2>&1`
13
+ stdout = `#{build_command(cmd)} 2>&1`
14
14
  # In ruby 1.9, it is possible to use Open3.capture3, but not in 1.8
15
15
  #stdout, stderr, status = Open3.capture3(cmd)
16
16
 
@@ -23,6 +23,13 @@ module Serverspec
23
23
  :exit_status => $?, :exit_signal => nil }
24
24
  end
25
25
 
26
+ def build_command(cmd)
27
+ if ! RSpec.configuration.path.nil?
28
+ cmd = "PATH=#{RSpec.configuration.path}:$PATH #{cmd}"
29
+ end
30
+ cmd
31
+ end
32
+
26
33
  def check_zero(cmd, *args)
27
34
  ret = run_command(commands.send(cmd, *args))
28
35
  ret[:exit_status] == 0
@@ -4,7 +4,7 @@ module Serverspec
4
4
  module Backend
5
5
  class Ssh < Exec
6
6
  def run_command(cmd, opt={})
7
- cmd = "PATH=/sbin:/usr/sbin:$PATH #{cmd}"
7
+ cmd = build_command(cmd)
8
8
  cmd = "sudo #{cmd}" if not RSpec.configuration.ssh.options[:user] == 'root'
9
9
  ret = ssh_exec!(cmd)
10
10
  if ! @example.nil?
@@ -0,0 +1,9 @@
1
+ module Serverspec
2
+ module Helper
3
+ module Base
4
+ def commands
5
+ Serverspec::Commands::Base.new
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.4.12"
2
+ VERSION = "0.4.13"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ require 'serverspec/helper/exec'
4
+ require 'serverspec/helper/base'
5
+ include Serverspec::Helper::Exec
6
+ include Serverspec::Helper::Base
7
+
8
+ describe 'Default path setting' do
9
+ subject { backend.build_command('service httpd status') }
10
+ it { should eq 'service httpd status' }
11
+ end
12
+
13
+ describe 'Custom path setting' do
14
+ before :all do
15
+ RSpec.configure do |c|
16
+ c.path = '/usr/local/rbenv/shims:/sbin:/usr/sbin'
17
+ end
18
+ end
19
+ subject { backend.build_command('service httpd status') }
20
+ it { should eq 'PATH=/usr/local/rbenv/shims:/sbin:/usr/sbin:$PATH service httpd status' }
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-27 00:00:00.000000000 Z
12
+ date: 2013-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -156,6 +156,7 @@ files:
156
156
  - lib/serverspec/filter.rb
157
157
  - lib/serverspec/helper.rb
158
158
  - lib/serverspec/helper/attributes.rb
159
+ - lib/serverspec/helper/base.rb
159
160
  - lib/serverspec/helper/darwin.rb
160
161
  - lib/serverspec/helper/debian.rb
161
162
  - lib/serverspec/helper/detect_os.rb
@@ -233,6 +234,7 @@ files:
233
234
  - lib/serverspec/type/zfs.rb
234
235
  - lib/serverspec/version.rb
235
236
  - serverspec.gemspec
237
+ - spec/backend/exec_spec.rb
236
238
  - spec/darwin/command_spec.rb
237
239
  - spec/darwin/commands_spec.rb
238
240
  - spec/darwin/cron_spec.rb
@@ -354,6 +356,7 @@ signing_key:
354
356
  specification_version: 3
355
357
  summary: RSpec tests for your servers provisioned by Puppet, Chef or anything else
356
358
  test_files:
359
+ - spec/backend/exec_spec.rb
357
360
  - spec/darwin/command_spec.rb
358
361
  - spec/darwin/commands_spec.rb
359
362
  - spec/darwin/cron_spec.rb