rspec-system 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/lib/rspec-system.rb +1 -0
- data/lib/rspec-system/exception.rb +9 -0
- data/lib/rspec-system/helper.rb +10 -1
- data/lib/rspec-system/helpers.rb +4 -0
- data/resources/prefabs.yml +8 -0
- data/rspec-system.gemspec +2 -2
- data/spec/system/shell_spec.rb +14 -0
- metadata +4 -3
data/CHANGELOG.md
CHANGED
data/lib/rspec-system.rb
CHANGED
data/lib/rspec-system/helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rspec-system'
|
2
2
|
require 'rspec-system/result'
|
3
3
|
require 'rspec-system/internal_helpers'
|
4
|
+
require 'timeout'
|
4
5
|
|
5
6
|
module RSpecSystem
|
6
7
|
# This class represents an abstract 'helper' object.
|
@@ -74,6 +75,7 @@ module RSpecSystem
|
|
74
75
|
opts = {
|
75
76
|
:node => opts[:n] || dn,
|
76
77
|
:n => opts[:node] || dn,
|
78
|
+
:timeout => opts[:timeout] || 0,
|
77
79
|
:lazy => lazy,
|
78
80
|
}.merge(opts)
|
79
81
|
|
@@ -109,7 +111,14 @@ module RSpecSystem
|
|
109
111
|
# @api private
|
110
112
|
def result_data
|
111
113
|
return rd unless rd.nil?
|
112
|
-
|
114
|
+
|
115
|
+
begin
|
116
|
+
Timeout::timeout(opts[:timeout]) do
|
117
|
+
@rd = RSpecSystem::Result.new(execute)
|
118
|
+
end
|
119
|
+
rescue Timeout::Error => e
|
120
|
+
raise RSpecSystem::Exception::TimeoutError, e.message
|
121
|
+
end
|
113
122
|
end
|
114
123
|
|
115
124
|
# Refresh the data, re-running the action associated with this helper.
|
data/lib/rspec-system/helpers.rb
CHANGED
@@ -79,6 +79,8 @@ module RSpecSystem::Helpers
|
|
79
79
|
# default in your YAML file, otherwise if there is only one node it uses
|
80
80
|
# that) specifies node to execute command on.
|
81
81
|
# @option options [RSpecSystem::Node] :n alias for :node
|
82
|
+
# @option options [Fixnum] :timeout seconds of time to allow before timing
|
83
|
+
# out. Defaults to 0 (not timeout).
|
82
84
|
# @overload shell(command)
|
83
85
|
# @param command [String] command to execute
|
84
86
|
# @yield [result] yields result when called as a block
|
@@ -136,6 +138,8 @@ module RSpecSystem::Helpers
|
|
136
138
|
# @option options [RSpecSystem::Node] :source_node ('') Reserved
|
137
139
|
# for future use. Patches welcome.
|
138
140
|
# @option options [RSpecSystem::Node] :s alias for source_node
|
141
|
+
# @option options [Fixnum] :timeout seconds of time to allow before timing
|
142
|
+
# out. Defaults to 0 (no timeout).
|
139
143
|
# @yield [result] yields result when called as a block
|
140
144
|
# @yieldparam result [RSpecSystem::Helpers::Rcp] result of rcp
|
141
145
|
# @return [RSpecSystem::Helpers::Rcp] result of rcp
|
data/resources/prefabs.yml
CHANGED
@@ -80,6 +80,11 @@
|
|
80
80
|
kernelversion: "2.6.32"
|
81
81
|
operatingsystemrelease: "6.4"
|
82
82
|
osfamily: RedHat
|
83
|
+
lsbmajdistrelease: "6"
|
84
|
+
lsbdistcodename: Final
|
85
|
+
lsbdistdescription: "CentOS release 6.4 (Final)"
|
86
|
+
lsbdistid: CentOS
|
87
|
+
lsbdistrelease: "6.4"
|
83
88
|
kernel: Linux
|
84
89
|
rubyversion: "1.8.7"
|
85
90
|
provider_specifics:
|
@@ -99,6 +104,9 @@
|
|
99
104
|
kernelrelease: 3.6.10-4.fc18.x86_64
|
100
105
|
kernelversion: 3.6.10
|
101
106
|
operatingsystemrelease: "18"
|
107
|
+
lsbdistid: Fedora
|
108
|
+
lsbmajdistrelease: "18"
|
109
|
+
lsbdistrelease: "18"
|
102
110
|
osfamily: RedHat
|
103
111
|
rubyversion: 1.9.3
|
104
112
|
provider_specifics:
|
data/rspec-system.gemspec
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
# Metadata
|
4
4
|
s.name = "rspec-system"
|
5
|
-
s.version = "2.1.
|
5
|
+
s.version = "2.1.1"
|
6
6
|
s.authors = ["Ken Barber"]
|
7
|
-
s.email = ["
|
7
|
+
s.email = ["info@puppetlabs.com"]
|
8
8
|
s.homepage = "https://github.com/puppetlabs/rspec-system"
|
9
9
|
s.summary = "System testing with rspec"
|
10
10
|
|
data/spec/system/shell_spec.rb
CHANGED
@@ -121,6 +121,20 @@ describe "shell:" do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
124
|
+
|
125
|
+
describe 'timeouts' do
|
126
|
+
it 'should throw exception if the command times out' do
|
127
|
+
expect { shell(:c => 'sleep 2', :timeout => 1) }.to raise_error(RSpecSystem::Exception::TimeoutError, 'execution expired')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should complete fine if command completed within timeout' do
|
131
|
+
shell(:c => 'sleep 1', :timeout => 5) do |r|
|
132
|
+
r.stdout.should == ''
|
133
|
+
r.stderr.should == ''
|
134
|
+
r.exit_code.should == 0
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
124
138
|
end
|
125
139
|
|
126
140
|
# Test as a top-level subject
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
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-
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -125,7 +125,7 @@ dependencies:
|
|
125
125
|
version: 1.5.9
|
126
126
|
description:
|
127
127
|
email:
|
128
|
-
-
|
128
|
+
- info@puppetlabs.com
|
129
129
|
executables: []
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- examples/spec/system/test2_spec.rb
|
150
150
|
- examples/spec/system/test3_spec.rb
|
151
151
|
- lib/rspec-system.rb
|
152
|
+
- lib/rspec-system/exception.rb
|
152
153
|
- lib/rspec-system/formatter.rb
|
153
154
|
- lib/rspec-system/helper.rb
|
154
155
|
- lib/rspec-system/helpers.rb
|