rspec-system 2.1.0 → 2.1.1

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.
@@ -1,3 +1,10 @@
1
+ 2.1.1
2
+ =====
3
+
4
+ This bug fix only adds lsb_* facts to the prefabs for: centos-64 and fedora-18
5
+
6
+ -------------------------------
7
+
1
8
  2.1.0
2
9
  =====
3
10
 
@@ -3,6 +3,7 @@ require 'rspec'
3
3
  # Root module namespace for +rspec-system+
4
4
  module RSpecSystem; end
5
5
 
6
+ require 'rspec-system/exception'
6
7
  require 'rspec-system/util'
7
8
  require 'rspec-system/log'
8
9
  require 'rspec-system/helper'
@@ -0,0 +1,9 @@
1
+ require 'rspec-system'
2
+
3
+ module RSpecSystem::Exception
4
+ # Parent for all RSpecSystem exceptions
5
+ class Error < StandardError; end
6
+
7
+ # General timeout error
8
+ class TimeoutError < Error; end
9
+ end
@@ -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
- @rd = RSpecSystem::Result.new(execute)
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.
@@ -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
@@ -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:
@@ -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.0"
5
+ s.version = "2.1.1"
6
6
  s.authors = ["Ken Barber"]
7
- s.email = ["ken@bob.sh"]
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
 
@@ -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.0
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-06-18 00:00:00.000000000 Z
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
- - ken@bob.sh
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