specinfra-backend-docker_lxc 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1c14192777898a3b3aa32dc8b8f9da1c63b7b94
4
- data.tar.gz: 77ad983a32d05ab822792931e4dfd46292c2643b
3
+ metadata.gz: 205092fd876ad0d24c719b36a4daf0646b311028
4
+ data.tar.gz: 5b16ef9c6bbb5a7fe3b85b669aea125c7152170d
5
5
  SHA512:
6
- metadata.gz: b758cc718f35faee74d97e85fa018dedbf90809232e3ceac19061f292490c78640d362d40021e5e466a9ff691a23ad5299fc2484ce8b8190ec41046955a478f5
7
- data.tar.gz: 8d6295e0d1aae74f40bff56d3f0e5ef6a63ff502cf6d643d6a0fffb7421db57b2c4dada2e8d4a25ae957070a1e58803f3263bb9f3a9a715000eb45e6b60b1420
6
+ metadata.gz: 3d20cf3cfd4ca86f6daf8fceac757176ba52cfcb5552596e1f4a725aa463f20cb542518d1256b1687c4bea383ff745ff33e805f491dadd62e1cfacd5f0b30e6a
7
+ data.tar.gz: 9787c72deff72df7287db47a9682ef745de5cf29da19d6fdacf1570ca153faaa743c0a3074ebc7c9b8a9afd8a4024bb4cf6ad3352c71c35fa6d0cdb59982605e
@@ -2,6 +2,12 @@
2
2
 
3
3
  This file is used to list changes made in each version of `specinfra-backend-docker_lxc`.
4
4
 
5
+ ## 0.2.0 (2015-11-16)
6
+
7
+ * Set RSpec metadata used by Serverspec.
8
+ * Improve code indentation a little.
9
+ * Documentation: Add some missing dots and spacing.
10
+
5
11
  ## 0.1.0 (2015-11-14)
6
12
 
7
- * Initial release of `specinfra-backend-docker_lxc`
13
+ * Initial release of `specinfra-backend-docker_lxc`.
data/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  [![Dependency Status](http://img.shields.io/gemnasium/zuazo/specinfra-backend-docker_lxc.svg?style=flat)](https://gemnasium.com/zuazo/specinfra-backend-docker_lxc)
4
4
  [![Code Climate](http://img.shields.io/codeclimate/github/zuazo/specinfra-backend-docker_lxc.svg?style=flat)](https://codeclimate.com/github/zuazo/specinfra-backend-docker_lxc)
5
5
  [![Circle CI](https://circleci.com/gh/zuazo/specinfra-backend-docker_lxc/tree/master.svg?style=shield)](https://circleci.com/gh/zuazo/specinfra-backend-docker_lxc/tree/master)
6
- [![Travis CI](http://img.shields.io/travis/zuazo/specinfra-backend-docker_lxc/0.1.0.svg?style=flat)](https://travis-ci.org/zuazo/specinfra-backend-docker_lxc)
7
- [![Coverage Status](http://img.shields.io/coveralls/zuazo/specinfra-backend-docker_lxc/0.1.0.svg?style=flat)](https://coveralls.io/r/zuazo/specinfra-backend-docker_lxc?branch=0.1.0)
6
+ [![Travis CI](http://img.shields.io/travis/zuazo/specinfra-backend-docker_lxc/0.2.0.svg?style=flat)](https://travis-ci.org/zuazo/specinfra-backend-docker_lxc)
7
+ [![Coverage Status](http://img.shields.io/coveralls/zuazo/specinfra-backend-docker_lxc/0.2.0.svg?style=flat)](https://coveralls.io/r/zuazo/specinfra-backend-docker_lxc?branch=0.2.0)
8
8
  [![Inline docs](http://inch-ci.org/github/zuazo/specinfra-backend-docker_lxc.svg?branch=master&style=flat)](http://inch-ci.org/github/zuazo/specinfra-backend-docker_lxc)
9
9
 
10
- [Serverspec](http://serverspec.org/)/[Specinfra](https://github.com/mizzy/specinfra) backend for Docker LXC execution driver.
10
+ [Serverspec](http://serverspec.org/) / [Specinfra](https://github.com/mizzy/specinfra) backend for Docker LXC execution driver.
11
11
 
12
12
  ## Requirements
13
13
 
@@ -22,7 +22,7 @@ Add this line to your application's Gemfile:
22
22
  ```ruby
23
23
  # Gemfile
24
24
 
25
- gem 'specinfra-backend-docker_lxc', '~> 0.1.0'
25
+ gem 'specinfra-backend-docker_lxc', '~> 0.2.0'
26
26
  ```
27
27
 
28
28
  And then execute:
@@ -59,13 +59,31 @@ module Specinfra
59
59
  # @param stderr [String] the *stderr* output.
60
60
  # @param status [Fixnum] the command exit status.
61
61
  # @return [Specinfra::CommandResult] the generated result object.
62
- def erroneous_result(exception, stdout, stderr, status)
62
+ def erroneous_result(cmd, exception, stdout, stderr, status)
63
63
  err =
64
- stderr.nil? ? ([exception.message] + exception.backtrace) : [stderr]
64
+ if stderr.nil?
65
+ [exception.message] + exception.backtrace
66
+ else
67
+ [stderr]
68
+ end
65
69
  sta = status.is_a?(Fixnum) && status != 0 ? status : 1
70
+ rspec_example_metadata(cmd, stdout, err.join)
66
71
  CommandResult.new(stdout: stdout, stderr: err.join, exit_status: sta)
67
72
  end
68
73
 
74
+ # Updates RSpec metadata used by Serverspec.
75
+ #
76
+ # @param cmd [Array<String>, String] the command (without `lxc-attach`).
77
+ # @param stdout [String] the *stdout* output.
78
+ # @param stderr [String] the *stderr* output.
79
+ # @return nil
80
+ def rspec_example_metadata(cmd, stdout, stderr)
81
+ return unless @example
82
+ @example.metadata[:command] = escape_command(cmd)
83
+ @example.metadata[:stdout] = stdout
84
+ @example.metadata[:stderr] = stderr
85
+ end
86
+
69
87
  # Runs a command inside a Docker container.
70
88
  #
71
89
  # @param cmd [String] the command to run.
@@ -74,14 +92,13 @@ module Specinfra
74
92
  def docker_run!(cmd, opts = {})
75
93
  stdout, stderr, status = shell_command!(lxc_attach_command(cmd), opts)
76
94
  lxc_attach_result_assert(stderr, status)
77
- CommandResult.new(
78
- stdout: stdout, stderr: stderr, exit_status: status
79
- )
95
+ rspec_example_metadata(cmd, stdout, stderr)
96
+ CommandResult.new(stdout: stdout, stderr: stderr, exit_status: status)
80
97
  rescue LxcAttachError
81
98
  raise
82
99
  rescue => e
83
100
  @container.kill
84
- erroneous_result(e, stdout, stderr, status)
101
+ erroneous_result(cmd, e, stdout, stderr, status)
85
102
  end
86
103
  end
87
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra-backend-docker_lxc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xabier de Zuazo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-14 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: specinfra
@@ -178,7 +178,7 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '2.24'
181
- description: Serverspec/Specinfra backend for Docker LXC execution driver.
181
+ description: Serverspec / Specinfra backend for Docker LXC execution driver.
182
182
  email: xabier@zuazo.org
183
183
  executables: []
184
184
  extensions: []