rspec-system 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/rspec-system/helpers.rb +12 -8
- data/lib/rspec-system/result.rb +11 -0
- data/lib/rspec-system.rb +1 -0
- data/rspec-system.gemspec +1 -1
- data/spec/system/system_rcp_spec.rb +2 -2
- data/spec/system/system_run_spec.rb +15 -8
- data/spec/unit/result_spec.rb +13 -0
- metadata +5 -2
data/README.md
CHANGED
@@ -43,7 +43,7 @@ Create the directory `spec/system` in your project, its recommended to make sure
|
|
43
43
|
describe 'basics' do
|
44
44
|
it 'should cat /etc/resolv.conf' do
|
45
45
|
system_run('cat /etc/resolv.conf') do |r|
|
46
|
-
r
|
46
|
+
r.stdout.should =~ /localhost/
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/lib/rspec-system/helpers.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec-system/result'
|
2
|
+
|
1
3
|
# This module contains the main rspec helpers that are to be used within
|
2
4
|
# rspec-system tests. These are the meat-and-potatoes of your system tests,
|
3
5
|
# and in theory there shouldn't be anything you can't do without the helpers
|
@@ -20,8 +22,8 @@
|
|
20
22
|
# describe 'test running' do
|
21
23
|
# it 'run cat' do
|
22
24
|
# system_run 'cat /etc/resolv.conf' do |r|
|
23
|
-
# r
|
24
|
-
# r
|
25
|
+
# r.exit_code.should == 0
|
26
|
+
# r.stdout.should =~ /localhost/
|
25
27
|
# end
|
26
28
|
# end
|
27
29
|
# end
|
@@ -59,9 +61,9 @@
|
|
59
61
|
# it 'test installing latest puppet' do
|
60
62
|
# install_puppet
|
61
63
|
# system_run('puppet apply --version') do |r|
|
62
|
-
# r
|
63
|
-
# r
|
64
|
-
# r
|
64
|
+
# r.exit_code == 0
|
65
|
+
# r.stdout.should =~ /3.1/
|
66
|
+
# r.stderr.should == ''
|
65
67
|
# end
|
66
68
|
# end
|
67
69
|
# end
|
@@ -92,8 +94,10 @@ module RSpecSystem::Helpers
|
|
92
94
|
# that) specifies node to execute command on.
|
93
95
|
# @option options [RSpecSystem::Node] :n alias for :node
|
94
96
|
# @yield [result] yields result when called as a block
|
95
|
-
# @yieldparam result [
|
96
|
-
#
|
97
|
+
# @yieldparam result [RSpecSystem::Result] a result containing :exit_code,
|
98
|
+
# :stdout and :stderr
|
99
|
+
# @return [RSpecSystem::Result] a result containing :exit_code, :stdout and
|
100
|
+
# :stderr
|
97
101
|
def system_run(options)
|
98
102
|
ns = rspec_system_node_set
|
99
103
|
dn = ns.default_node
|
@@ -116,7 +120,7 @@ module RSpecSystem::Helpers
|
|
116
120
|
raise "Cannot use system_run with no :command option"
|
117
121
|
end
|
118
122
|
|
119
|
-
result = ns.run(options)
|
123
|
+
result = RSpecSystem::Result.new(ns.run(options))
|
120
124
|
|
121
125
|
if block_given?
|
122
126
|
yield(result)
|
data/lib/rspec-system.rb
CHANGED
data/rspec-system.gemspec
CHANGED
@@ -8,8 +8,8 @@ describe "system_rcp:" do
|
|
8
8
|
)
|
9
9
|
|
10
10
|
system_run('cat /tmp/example_destination/example_file') do |r|
|
11
|
-
r
|
12
|
-
r
|
11
|
+
r.exit_code.should == 0
|
12
|
+
r.stdout.should =~ /Test content 1234/
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -2,6 +2,13 @@ require 'spec_helper_system'
|
|
2
2
|
|
3
3
|
describe "system_run:" do
|
4
4
|
it "cat /etc/hosts" do
|
5
|
+
system_run("cat /etc/hosts") do |r|
|
6
|
+
r.exit_code.should == 0
|
7
|
+
r.stdout.should =~ /localhost/
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "cat /etc/hosts - test results using hash method" do
|
5
12
|
system_run("cat /etc/hosts") do |r|
|
6
13
|
r[:exit_code].should == 0
|
7
14
|
r[:stdout].should =~ /localhost/
|
@@ -11,13 +18,13 @@ describe "system_run:" do
|
|
11
18
|
it 'piping should be preserved' do
|
12
19
|
system_run('rm -f /tmp/foo')
|
13
20
|
system_run('echo "foo" > /tmp/foo') do |r|
|
14
|
-
r
|
15
|
-
r
|
21
|
+
r.stderr.should == ''
|
22
|
+
r.exit_code.should == 0
|
16
23
|
end
|
17
24
|
|
18
25
|
system_run('cat /tmp/foo') do |r|
|
19
|
-
r
|
20
|
-
r
|
26
|
+
r.stdout.should =~ /foo/
|
27
|
+
r.exit_code.should == 0
|
21
28
|
end
|
22
29
|
system_run('rm -f /tmp/foo')
|
23
30
|
end
|
@@ -25,13 +32,13 @@ describe "system_run:" do
|
|
25
32
|
it 'escape single quotes properly' do
|
26
33
|
system_run('rm -f /tmp/foo')
|
27
34
|
system_run("echo 'foo' > /tmp/foo") do |r|
|
28
|
-
r
|
29
|
-
r
|
35
|
+
r.stderr.should == ''
|
36
|
+
r.exit_code.should == 0
|
30
37
|
end
|
31
38
|
|
32
39
|
system_run('cat /tmp/foo') do |r|
|
33
|
-
r
|
34
|
-
r
|
40
|
+
r.stdout.should =~ /foo/
|
41
|
+
r.exit_code.should == 0
|
35
42
|
end
|
36
43
|
system_run('rm -f /tmp/foo')
|
37
44
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RSpecSystem::Result do
|
4
|
+
it 'should allow you to query using methods' do
|
5
|
+
result = subject.class.new(:foo => 'bar')
|
6
|
+
result.foo.should == 'bar'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should allow you to query using hash queries' do
|
10
|
+
result = subject.class.new(:foo => 'bar')
|
11
|
+
result[:foo].should == 'bar'
|
12
|
+
end
|
13
|
+
end
|
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: 1.
|
4
|
+
version: 1.2.0
|
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-05-
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/rspec-system/node_set/vsphere.rb
|
143
143
|
- lib/rspec-system/prefab.rb
|
144
144
|
- lib/rspec-system/rake_task.rb
|
145
|
+
- lib/rspec-system/result.rb
|
145
146
|
- lib/rspec-system/spec_helper.rb
|
146
147
|
- resources/kwalify-schemas/nodeset_schema.yml
|
147
148
|
- resources/kwalify-schemas/prefabs_schema.yml
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- spec/system/system_run_spec.rb
|
157
158
|
- spec/unit/kwalify-schemas/nodeset_schema_spec.rb
|
158
159
|
- spec/unit/kwalify-schemas/prefabs_schema_spec.rb
|
160
|
+
- spec/unit/result_spec.rb
|
159
161
|
homepage: https://github.com/puppetlabs/rspec-system
|
160
162
|
licenses: []
|
161
163
|
post_install_message:
|
@@ -186,3 +188,4 @@ test_files:
|
|
186
188
|
- spec/system/system_run_spec.rb
|
187
189
|
- spec/unit/kwalify-schemas/nodeset_schema_spec.rb
|
188
190
|
- spec/unit/kwalify-schemas/prefabs_schema_spec.rb
|
191
|
+
- spec/unit/result_spec.rb
|