specinfra 2.0.0.beta14 → 2.0.0.beta15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26a24975924d84841a016386588bb54c094b94da
4
- data.tar.gz: b0e847c24fb0dd945b0f68018ec54372eb6bdfc3
3
+ metadata.gz: 52cbcd87131d03d42e7afa46dbdc4fcc4d249352
4
+ data.tar.gz: f77e622fc12d536070800b2ed9ffcb9073aa2c9d
5
5
  SHA512:
6
- metadata.gz: 5437fca57eea9b86e5a3d885c32bc48e1f8c4fe55a9606421e02b9d55736a9e40542a63b0810f3f4aae646dfae75b778a9f3892d77f1d165848e68d2e3adbd21
7
- data.tar.gz: b3b5647f3d39399cc0bf073aa6958e1666f88a79a758e5f0f89142a341dd56e22130d1a8f213b3f1cf4ffa642a218b11720d6c8ac8132bc4da70c51b384d1cfc
6
+ metadata.gz: 8cd425df44198ad44995b4b1b4fed47f36297bde6e208abedce59aed7f3b34a0889fc94b13514befc87e59edcb187400b3b29a28ce6c185f9c10f1f7eea42ecd
7
+ data.tar.gz: a2f79a8bdfe210b9050f9e3560156ee1d28bb6eff02e20714f6ae901a6912ac64699bb1d2beafbccf44d7d56a3e5e4fc28b453e7156a0f0d7851d62b8fc3d761
data/lib/specinfra.rb CHANGED
@@ -17,6 +17,11 @@ module Specinfra
17
17
  def command
18
18
  Specinfra::Command::Base.new
19
19
  end
20
+
21
+ def backend
22
+ type = Specinfra.configuration.backend.to_s.to_camel_case
23
+ eval "Specinfra::Backend::#{type}.instance"
24
+ end
20
25
  end
21
26
  end
22
27
 
@@ -7,31 +7,19 @@ module Specinfra
7
7
  class Base
8
8
  include Singleton
9
9
 
10
- def set_commands(c)
11
- @commands = c
12
- end
13
-
14
10
  def set_example(e)
15
11
  @example = e
16
12
  end
17
13
 
18
- def commands
19
- @commands
20
- end
21
-
22
14
  def check_zero(cmd, *args)
23
15
  run_command(Specinfra.command.send(cmd, *args)).success?
24
16
  end
25
17
 
26
18
  def method_missing(meth, *args, &block)
27
- if os[:family] == 'windows'
28
- if meth.to_s =~ /^check/
29
- backend.check_zero(meth, *args)
30
- else
31
- backend.run_command(Specinfra.command.send(meth, *args))
32
- end
19
+ if meth.to_s =~ /^check/
20
+ check_zero(meth, *args)
33
21
  else
34
- Specinfra::Command::Processor.send(meth, *args)
22
+ run_command(Specinfra.command.send(meth, *args))
35
23
  end
36
24
  end
37
25
  end
@@ -1,15 +1,11 @@
1
1
  module Specinfra::Command
2
2
  class Processor
3
3
  def self.method_missing(meth, *args, &block)
4
- if meth.to_s =~ /^check/
5
- backend.check_zero(meth, *args)
6
- else
7
- backend.run_command(Specinfra.command.send(meth, *args))
8
- end
4
+ Specinfra.backend.send(meth, *args)
9
5
  end
10
6
 
11
7
  def self.check_service_is_running(service)
12
- ret = backend.run_command(Specinfra.command.check_service_is_running(service))
8
+ ret = Specinfra.backend.run_command(Specinfra.command.check_service_is_running(service))
13
9
 
14
10
  # In Ubuntu, some services are under upstart and "service foo status" returns
15
11
  # exit status 0 even though they are stopped.
@@ -18,14 +14,14 @@ module Specinfra::Command
18
14
 
19
15
  # If the service is not registered, check by ps command
20
16
  if ret.exit_status == 1
21
- ret = backend.run_command(Specinfra.command.check_process_is_running(service))
17
+ ret = Specinfra.backend.run_command(Specinfra.command.check_process_is_running(service))
22
18
  end
23
19
 
24
20
  ret.success?
25
21
  end
26
22
 
27
23
  def self.check_service_is_monitored_by_monit(process)
28
- ret = backend.run_command(Specinfra.command.check_service_is_monitored_by_monit(process))
24
+ ret = Specinfra.backend.run_command(Specinfra.command.check_service_is_monitored_by_monit(process))
29
25
  return false unless ret.stdout != nil && ret.success?
30
26
 
31
27
  retlines = ret.stdout.split(/[\r\n]+/).map(&:strip)
@@ -36,7 +32,7 @@ module Specinfra::Command
36
32
  end
37
33
 
38
34
  def self.check_file_is_readable(file, by_whom)
39
- mode = sprintf('%04s',backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
35
+ mode = sprintf('%04s',Specinfra.backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
40
36
  mode = mode.split('')
41
37
  mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
42
38
  case by_whom
@@ -52,7 +48,7 @@ module Specinfra::Command
52
48
  end
53
49
 
54
50
  def self.check_file_is_writable(file, by_whom)
55
- mode = sprintf('%04s',backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
51
+ mode = sprintf('%04s',Specinfra.backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
56
52
  mode = mode.split('')
57
53
  mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
58
54
  case by_whom
@@ -68,7 +64,7 @@ module Specinfra::Command
68
64
  end
69
65
 
70
66
  def self.check_file_is_executable(file, by_whom)
71
- mode = sprintf('%04s',backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
67
+ mode = sprintf('%04s',Specinfra.backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
72
68
  mode = mode.split('')
73
69
  mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
74
70
  case by_whom
@@ -84,7 +80,7 @@ module Specinfra::Command
84
80
  end
85
81
 
86
82
  def self.check_file_is_mounted(path, expected_attr, only_with)
87
- ret = backend.run_command(Specinfra.command.check_file_is_mounted(path))
83
+ ret = Specinfra.backend.run_command(Specinfra.command.check_file_is_mounted(path))
88
84
  if expected_attr.nil? || ret.failure?
89
85
  return ret.success?
90
86
  end
@@ -118,7 +114,7 @@ module Specinfra::Command
118
114
 
119
115
  def self.check_routing_table_has_entry(expected_attr)
120
116
  return false if ! expected_attr[:destination]
121
- ret = backend.get_routing_table_entry(expected_attr[:destination])
117
+ ret = Specinfra.backend.get_routing_table_entry(expected_attr[:destination])
122
118
  return false if ret.failure?
123
119
 
124
120
  ret.stdout.gsub!(/\r\n/, "\n")
@@ -2,6 +2,7 @@ module Specinfra
2
2
  module Configuration
3
3
  class << self
4
4
  VALID_OPTIONS_KEYS = [
5
+ :backend,
5
6
  :env,
6
7
  :path,
7
8
  :shell,
@@ -1,9 +1,6 @@
1
1
  require 'specinfra/helper/os'
2
2
  include Specinfra::Helper::Os
3
3
 
4
- require 'specinfra/helper/backend'
5
- include Specinfra::Helper::Backend
6
-
7
4
  require 'specinfra/helper/docker'
8
5
  require 'specinfra/helper/lxc'
9
6
 
@@ -30,7 +30,7 @@ module Specinfra::Helper::Os
30
30
  end
31
31
 
32
32
  def run_command(cmd)
33
- backend.run_command(cmd)
33
+ Specinfra.backend.run_command(cmd)
34
34
  end
35
35
 
36
36
  def detect_os
@@ -2,7 +2,11 @@ module Specinfra
2
2
  class Runner
3
3
  include Singleton
4
4
  def method_missing(meth, *args, &block)
5
- backend.send(meth, *args)
5
+ if os.include?(:family) && os[:family] == 'windows'
6
+ Specinfra.backend.send(meth, *args)
7
+ else
8
+ Specinfra::Command::Processor.send(meth, *args)
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.0.0.beta14"
2
+ VERSION = "2.0.0.beta15"
3
3
  end
@@ -1,18 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Specinfra::Helper::Exec
4
-
5
3
  describe Specinfra::Backend::Exec do
6
4
  describe '#build_command' do
7
5
  context 'with simple command' do
8
6
  it 'should escape spaces' do
9
- expect(backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
7
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
10
8
  end
11
9
  end
12
10
 
13
11
  context 'with complex command' do
14
12
  it 'should escape special chars' do
15
- expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
13
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
16
14
  end
17
15
  end
18
16
 
@@ -26,7 +24,7 @@ describe Specinfra::Backend::Exec do
26
24
  end
27
25
 
28
26
  it 'should use custom shell' do
29
- expect(backend.build_command('test -f /etc/passwd')).to eq '/usr/local/bin/tcsh -c test\ -f\ /etc/passwd'
27
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/usr/local/bin/tcsh -c test\ -f\ /etc/passwd'
30
28
  end
31
29
  end
32
30
 
@@ -40,7 +38,7 @@ describe Specinfra::Backend::Exec do
40
38
  end
41
39
 
42
40
  it 'should use custom shell' do
43
- expect(backend.build_command('test -f /etc/passwd')).to eq '/usr/test\ \&\ spec/bin/sh -c test\ -f\ /etc/passwd'
41
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/usr/test\ \&\ spec/bin/sh -c test\ -f\ /etc/passwd'
44
42
  end
45
43
  end
46
44
 
@@ -54,7 +52,7 @@ describe Specinfra::Backend::Exec do
54
52
  end
55
53
 
56
54
  it 'should use custom path' do
57
- expect(backend.build_command('test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/foo/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
55
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/foo/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
58
56
  end
59
57
  end
60
58
 
@@ -68,7 +66,7 @@ describe Specinfra::Backend::Exec do
68
66
  end
69
67
 
70
68
  it 'should use custom path' do
71
- expect(backend.build_command('test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/test & spec/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
69
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/test & spec/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
72
70
  end
73
71
  end
74
72
  end
@@ -83,7 +81,7 @@ describe 'os' do
83
81
  context 'test ubuntu with lsb_release command' do
84
82
  subject { os }
85
83
  it do
86
- expect(backend).to receive(:run_command).at_least(1).times do |args|
84
+ expect(Specinfra.backend).to receive(:run_command).at_least(1).times do |args|
87
85
  if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
88
86
  double(
89
87
  :run_command_response,
@@ -103,7 +101,7 @@ describe 'os' do
103
101
  context 'test ubuntu with /etc/lsb-release' do
104
102
  subject { os }
105
103
  it do
106
- expect(backend).to receive(:run_command).at_least(1).times do |args|
104
+ expect(Specinfra.backend).to receive(:run_command).at_least(1).times do |args|
107
105
  if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
108
106
  double(
109
107
  :run_command_response,
@@ -128,7 +126,7 @@ EOF
128
126
  context 'test debian (no lsb_release or lsb-release)' do
129
127
  subject { os }
130
128
  it do
131
- expect(backend).to receive(:run_command).at_least(1).times do |args|
129
+ expect(Specinfra.backend).to receive(:run_command).at_least(1).times do |args|
132
130
  if args == 'ls /etc/debian_version'
133
131
  double :run_command_response, :success? => true, :stdout => nil
134
132
  elsif args == 'uname -m'
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe backend.run_command('echo $LANG').stdout.strip do
3
+ describe Specinfra.backend.run_command('echo $LANG').stdout.strip do
4
4
  it { should eq 'C' }
5
5
  end
6
6
 
@@ -9,7 +9,7 @@ describe do
9
9
  ENV['LANG'] = 'C'
10
10
  set :env, :LANG => 'ja_JP.UTF-8'
11
11
  end
12
- let(:lang) { backend.run_command('echo $LANG').stdout.strip }
12
+ let(:lang) { Specinfra.backend.run_command('echo $LANG').stdout.strip }
13
13
  it { expect(lang).to eq 'ja_JP.UTF-8' }
14
14
  it { expect(ENV['LANG']).to eq 'C' }
15
15
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Specinfra::Helper::Ssh
3
+ set :backend, :ssh
4
4
 
5
5
  describe Specinfra::Backend::Ssh do
6
6
  describe '#build_command' do
@@ -13,11 +13,11 @@ describe Specinfra::Backend::Ssh do
13
13
  end
14
14
 
15
15
  it 'should not prepend sudo' do
16
- expect(backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
16
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
17
17
  end
18
18
 
19
19
  it 'should escape special characters' do
20
- expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
20
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
21
21
  end
22
22
  end
23
23
 
@@ -30,11 +30,11 @@ describe Specinfra::Backend::Ssh do
30
30
  end
31
31
 
32
32
  it 'should prepend sudo' do
33
- expect(backend.build_command('test -f /etc/passwd')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
33
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
34
34
  end
35
35
 
36
36
  it 'should escape special characters' do
37
- expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
37
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
38
38
  end
39
39
  end
40
40
 
@@ -54,11 +54,11 @@ describe Specinfra::Backend::Ssh do
54
54
  end
55
55
 
56
56
  it 'command pattern 1a' do
57
- expect(backend.build_command('test -f /etc/passwd')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
57
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
58
58
  end
59
59
 
60
60
  it 'command pattern 2a' do
61
- expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
61
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
62
62
  end
63
63
  end
64
64
 
@@ -78,11 +78,11 @@ describe Specinfra::Backend::Ssh do
78
78
  end
79
79
 
80
80
  it 'command pattern 1b' do
81
- expect(backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
81
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
82
82
  end
83
83
 
84
84
  it 'command pattern 2b' do
85
- expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
85
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
86
86
  end
87
87
 
88
88
  end
@@ -104,12 +104,12 @@ describe Specinfra::Backend::Ssh do
104
104
  end
105
105
 
106
106
  context 'command pattern 1a' do
107
- subject { backend.build_command('test -f /etc/passwd') }
107
+ subject { Specinfra.backend.build_command('test -f /etc/passwd') }
108
108
  it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd} }
109
109
  end
110
110
 
111
111
  context 'command pattern 2a' do
112
- subject { backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
112
+ subject { Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
113
113
  it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)} }
114
114
  end
115
115
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'specinfra'
2
2
  require 'rspec/mocks/standalone'
3
3
  require 'rspec/its'
4
4
 
5
- include Specinfra::Helper::Exec
5
+ set :backend, :exec
6
6
 
7
7
  module Specinfra
8
8
  module Backend
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta14
4
+ version: 2.0.0.beta15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -283,7 +283,6 @@ files:
283
283
  - lib/specinfra/command_result.rb
284
284
  - lib/specinfra/configuration.rb
285
285
  - lib/specinfra/helper.rb
286
- - lib/specinfra/helper/backend.rb
287
286
  - lib/specinfra/helper/configuration.rb
288
287
  - lib/specinfra/helper/detect_os.rb
289
288
  - lib/specinfra/helper/detect_os/aix.rb
@@ -315,7 +314,6 @@ files:
315
314
  - spec/command/redhat/interface_spec.rb
316
315
  - spec/command/redhat/package_spec.rb
317
316
  - spec/configuration_spec.rb
318
- - spec/helper/backend_spec.rb
319
317
  - spec/helper/os_spec.rb
320
318
  - spec/helper/properties_spec.rb
321
319
  - spec/helper/set_spec.rb
@@ -356,7 +354,6 @@ test_files:
356
354
  - spec/command/redhat/interface_spec.rb
357
355
  - spec/command/redhat/package_spec.rb
358
356
  - spec/configuration_spec.rb
359
- - spec/helper/backend_spec.rb
360
357
  - spec/helper/os_spec.rb
361
358
  - spec/helper/properties_spec.rb
362
359
  - spec/helper/set_spec.rb
@@ -1,27 +0,0 @@
1
- module Specinfra
2
- module Helper
3
- ['Exec', 'Ssh', 'Cmd', 'Docker', 'WinRM', 'ShellScript', 'Dockerfile', 'Lxc'].each do |type|
4
- eval <<-EOF
5
- module #{type}
6
- def backend(commands_object=nil)
7
- if ! respond_to?(:commands)
8
- commands_object = Specinfra::Command::Base.new
9
- end
10
- instance = Specinfra::Backend::#{type}.instance
11
- instance.set_commands(commands_object || commands)
12
- instance
13
- end
14
- end
15
- EOF
16
- end
17
-
18
- module Backend
19
- def backend_for(type)
20
- instance = self.class.const_get('Specinfra').const_get('Backend').const_get(type.to_s.capitalize).instance
21
- commands = Specinfra::Command::Base.new
22
- instance.set_commands(commands)
23
- instance
24
- end
25
- end
26
- end
27
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'backend_for(:type) returns correct backend object' do
4
- before do
5
- RSpec.configure do |c|
6
- c.ssh = double(:ssh, :options => { :user => 'root' })
7
- end
8
- end
9
-
10
- it 'backend_for(:exec) returns Specinfra::Backend::Exec' do
11
- expect(backend_for(:exec)).to be_an_instance_of Specinfra::Backend::Exec
12
- end
13
-
14
- it 'backend_for(:ssh) returns Specinfra::Backend::Ssh' do
15
- expect(backend_for(:ssh)).to be_an_instance_of Specinfra::Backend::Ssh
16
- end
17
- end