beaker-rspec 4.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2FjZjdiOGRkODFmMTRjZTkzNmFhZGRmZWYzYzY4Y2RiYmI0ZDIyNQ==
4
+ Y2JlNjhkMWE1ZDc4NjRkMjJjY2RmMzg1MWE4YTI2ZTVkNTg5OWViNg==
5
5
  data.tar.gz: !binary |-
6
- Y2MyOTg3NmNkYTAzODg1ZmFhYjgwMGYzNGIwYjM0Yzg1MDlkMTEyNw==
6
+ ODBmYzkwODQyYzFkNzlhYWRiNWJkNTJjOTVlZDg1YzMzZWI2MWYxNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzE4ZGM0YTRmNWIyYzM3ZmNmYzc2M2Y1YzQ5MmM2NzNiZmRjMzAzMTY2OWVh
10
- ODcxOThkZjRjMjM3MDhhOGNhYmM4ZGRhZmU2Y2YzYTMxMWNlMzgwZGIzYWFj
11
- NDJmODYxZTJlMDg3ZmZiNjc4YTE0ZjM5Yjc1YzQ1NGFjMTk0ZGU=
9
+ ZTMzNzI5MTY3YTQ2ZGI0MjA4ZDU1ZmFlNmY1MjE3NDliMTljNjEzNGVmNjBj
10
+ NDI1MmRmNTk4N2JhMzRiMmExMDRkZGM2Y2JhYmE0MTg1ZjhlZjk0ZGM4ODMy
11
+ ZjdlYTQ2NTM2ZWQzYzIxZDkyZjFkNjUzYjJlOTU0MGE2NTRlNmU=
12
12
  data.tar.gz: !binary |-
13
- YTNmZjZlYjM2YjUzYmIyYzQxNWExMzMzMzk4NjlmZjYwYzc4N2I4ZGYxYzU0
14
- M2UzNGJiN2JhZjAyYzdhZTRhNGZjMGExNzJiZTNiMmVmZWUzYzM0YjY5ZDI3
15
- MjJmYTZhOTM0ZDdjZjI1MDU1YjlkMDdlNjI5NTRlOWRiZDcxODc=
13
+ MTU2MDA0NzkwOGQwOWMyYTVkMDE1YWU0ZDM5MTRjODFiODAyYzQ1M2JiMmYw
14
+ NTE2OTdkMjk3NDM1YzBhYWUwNDdjOTg2YWY1ZDFlZDEzY2QxZTA2ODQyNTZk
15
+ MTYxNDE0MjVmMjNlNmY2ZWFlOTI5ODJkYTE1ZWZhZjM3YWVhMGY=
data/beaker-rspec.gemspec CHANGED
@@ -6,7 +6,7 @@ less_than_one_nine = ruby_conf['MAJOR'].to_i == 1 && ruby_conf['MINOR'].to_i < 9
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "beaker-rspec"
9
- s.version = '4.0.0'
9
+ s.version = '5.0.0'
10
10
  s.authors = ["Puppetlabs"]
11
11
  s.email = ["sqa@puppetlabs.com"]
12
12
  s.homepage = "https://github.com/puppetlabs/beaker-rspec"
@@ -34,6 +34,6 @@ Gem::Specification.new do |s|
34
34
  # Run time dependencies
35
35
  s.add_runtime_dependency 'beaker', '~> 2.0'
36
36
  s.add_runtime_dependency 'rspec'
37
- s.add_runtime_dependency 'serverspec', '~> 1.0'
38
- s.add_runtime_dependency 'specinfra', '~> 1.0'
37
+ s.add_runtime_dependency 'serverspec', '~> 2'
38
+ s.add_runtime_dependency 'specinfra', '~> 2'
39
39
  end
@@ -1,78 +1,91 @@
1
1
  require 'serverspec'
2
2
  require 'specinfra'
3
- require 'specinfra/backend/exec'
4
3
 
5
- module SpecInfra
6
- # Backend Module
7
- #
8
- # Contains the bridge between beaker-rspec and serverspec
9
- module Backend
10
- # Class BeakerExec
11
- #
12
- # Controls the running of Serverspec commands.
13
- class BeakerExec < SpecInfra::Backend::Exec
14
- # Run a command using serverspec. Defaults to running on the 'default' test node, otherwise uses the
15
- # node specified in @example.metadata[:node]
16
- # @param [String] cmd The serverspec command to executed
17
- # @param [Hash] opt No currently supported options
18
- # @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
19
- def run_command(cmd, opt={})
20
- cmd = build_command(cmd)
21
- cmd = add_pre_command(cmd)
22
- ret = ssh_exec!(cmd)
4
+ # Set specinfra backend to use our custom backend
5
+ set :backend, 'BeakerExec'
23
6
 
24
- if @example
25
- @example.metadata[:command] = cmd
26
- @example.metadata[:stdout] = ret[:stdout]
27
- end
7
+ # Override existing specinfra configuration to avoid conflicts
8
+ # with beaker's shell, stdout, stderr defines
9
+ module Specinfra
10
+ module Configuration
11
+ class << self
12
+ VALID_OPTIONS_KEYS = [
13
+ :backend,
14
+ :env,
15
+ :path,
16
+ :pre_command,
17
+ :sudo_path,
18
+ :disable_sudo,
19
+ :sudo_options,
20
+ :docker_image,
21
+ :docker_url,
22
+ :lxc,
23
+ :request_pty,
24
+ :ssh_options,
25
+ :dockerfile_finalizer,
26
+ ].freeze
27
+ end
28
+ end
29
+ end
30
+
31
+ module Specinfra::Backend
32
+ class BeakerExec < Specinfra::Backend::Base
33
+ # Run a command using serverspec. Defaults to running on the 'default' test node, otherwise uses the
34
+ # node specified in @example.metadata[:node]
35
+ # @param [String] cmd The serverspec command to executed
36
+ # @param [Hash] opt No currently supported options
37
+ # @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
38
+ def run_command(cmd, opt={})
39
+ cmd = build_command(cmd)
40
+ cmd = add_pre_command(cmd)
41
+ ret = ssh_exec!(cmd)
28
42
 
29
- CommandResult.new ret
43
+ if @example
44
+ @example.metadata[:command] = cmd
45
+ @example.metadata[:stdout] = ret[:stdout]
30
46
  end
31
47
 
32
- private
33
- # Execute the provided ssh command
34
- # @param [String] command The command to be executed
35
- # @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
36
- def ssh_exec!(command)
37
- if @example and @example.metadata[:node]
38
- node = @example.metadata[:node]
39
- else
40
- node = default
41
- end
48
+ CommandResult.new ret
49
+ end
42
50
 
43
- r = on node, command, { :acceptable_exit_codes => (0..127) }
44
- {
45
- :exit_status => r.exit_code,
46
- :stdout => r.stdout,
47
- :stderr => r.stderr
48
- }
51
+ # Execute the provided ssh command
52
+ # @param [String] command The command to be executed
53
+ # @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
54
+ def ssh_exec!(command)
55
+ if @example and @example.metadata[:node]
56
+ node = @example.metadata[:node]
57
+ else
58
+ node = default
49
59
  end
60
+ r = on node, command, { :acceptable_exit_codes => (0..127) }
61
+ {
62
+ :exit_status => r.exit_code,
63
+ :stdout => r.stdout,
64
+ :stderr => r.stderr
65
+ }
50
66
  end
51
- end
52
- end
53
67
 
68
+ def build_command(cmd)
69
+ useshell = '/bin/sh'
70
+ cmd = cmd.shelljoin if cmd.is_a?(Array)
71
+ cmd = "#{useshell.shellescape} -c #{cmd.shellescape}"
54
72
 
55
- module SpecInfra
56
- # Helper Module
57
- #
58
- #
59
- module Helper
60
- # BeakerBackend Module
61
- #
62
- module BeakerBackend
63
- # @param commands_object [Object] The command object
64
- # @return [SpecInfra::Backend::BeakerExec] Returns an instance of SpecInfra::Backend::BeakerExec
65
- def backend(commands_object=nil)
66
- if ! respond_to?(:commands)
67
- commands_object = SpecInfra::Commands::Base.new
68
- end
69
- instance = SpecInfra::Backend::BeakerExec.instance
70
- instance.set_commands(commands_object || commands)
71
- instance
73
+ path = Specinfra.configuration.path
74
+ if path
75
+ cmd = %Q{env PATH="#{path}" #{cmd}}
76
+ end
77
+
78
+ cmd
79
+ end
80
+
81
+ def add_pre_command(cmd)
82
+ if Specinfra.configuration.pre_command
83
+ pre_cmd = build_command(Specinfra.configuration.pre_command)
84
+ "#{pre_cmd} && #{cmd}"
85
+ else
86
+ cmd
72
87
  end
73
88
  end
89
+
74
90
  end
75
91
  end
76
-
77
- include SpecInfra::Helper::BeakerBackend
78
- include SpecInfra::Helper::DetectOS
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -142,28 +142,28 @@ dependencies:
142
142
  requirements:
143
143
  - - ~>
144
144
  - !ruby/object:Gem::Version
145
- version: '1.0'
145
+ version: '2'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ~>
151
151
  - !ruby/object:Gem::Version
152
- version: '1.0'
152
+ version: '2'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: specinfra
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ~>
158
158
  - !ruby/object:Gem::Version
159
- version: '1.0'
159
+ version: '2'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
- version: '1.0'
166
+ version: '2'
167
167
  description: RSpec bindings for beaker, see https://github.com/puppetlabs/beaker
168
168
  email:
169
169
  - sqa@puppetlabs.com