httpotemkin 0.0.2 → 0.0.3

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: a92d5f3c3c07552abf6abbff208200395c89cdef
4
- data.tar.gz: 519d81c4e618655ddc91f7971d7d80fb3258e81a
3
+ metadata.gz: 48d695b887bf805db229dfd7b257639a3f98af12
4
+ data.tar.gz: d1469f40788c40ad3fd2944cf938895b5d886ca1
5
5
  SHA512:
6
- metadata.gz: a7d91419dbf36b3a55f64dbc0968e14e496c0256fb3ae5b7ed4e1d8afce34ac0ff08f1b686ea239efe70a35e1a46c316dc7f82bbdb045dd8a049f27cf6ddcaf8
7
- data.tar.gz: b130318a0db1552d3cab9946ef5cb46a7b78f7238bea060e35f2cc623b974940446805eff8dc8a86ccb65c1d151ef5d37e9ef00ab5746d5d91afe36faa3d9f00
6
+ metadata.gz: 2d2145a1c62b5c6fd0285596d1e0b1e39344712d7058fe099c473412c6a4106dc1cb5b1422b2f55a334e4a1d0780f00af63f54e39e041d502d71e3b4fd9ab4ad
7
+ data.tar.gz: fb127a608dd4192ce60600aca6691723dd8ce9583878fa8aeff487669f420e100d23701a6d550fc0a1d21c6bf7f8c4f9ac1c2b09996c63ad9a51ff90968a7ff2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change log of httpotemkin
2
2
 
3
+ ## Version 0.0.3
4
+
5
+ * Capture stderr and exit code when running commands on the client
6
+
3
7
  ## Version 0.0.2
4
8
 
5
9
  * Support running servers and clients separate from executing the test. This
data/lib/client.rb CHANGED
@@ -1,23 +1,13 @@
1
1
  module Httpotemkin
2
2
  class Client
3
+ attr_reader :out, :err, :exit_code
4
+
3
5
  def initialize(containers)
4
6
  @containers = containers
5
7
  end
6
8
 
7
9
  def execute(cmd, working_directory: nil)
8
- @out = @containers.exec_client(cmd, working_directory: working_directory)
9
- end
10
-
11
- def exit_code
12
- 0
13
- end
14
-
15
- def out
16
- @out
17
- end
18
-
19
- def err
20
- ""
10
+ @out, @err, @exit_code = @containers.exec_client(cmd, working_directory: working_directory)
21
11
  end
22
12
 
23
13
  def inject_tarball(filename)
data/lib/containers.rb CHANGED
@@ -97,7 +97,15 @@ module Httpotemkin
97
97
  cmd += client_cmd
98
98
  end
99
99
  @out.puts cmd.join(" ")
100
- Cheetah.run(cmd, stdout: :capture)
100
+ begin
101
+ out, err = Cheetah.run(cmd, stdout: :capture, stderr: :capture)
102
+ exit_code = 0
103
+ rescue Cheetah::ExecutionFailed => e
104
+ out = e.stdout
105
+ err = e.stderr
106
+ exit_code = e.status.exitstatus
107
+ end
108
+ return out, err, exit_code
101
109
  end
102
110
 
103
111
  def links
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Httpotemkin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -67,4 +67,19 @@ describe "client" do
67
67
  expect(client.err.empty?).to be(true)
68
68
  end
69
69
  end
70
+
71
+ it "captures stderr" do
72
+ out = double
73
+ allow(out).to receive(:puts)
74
+
75
+ test = Httpotemkin::Test.new(out: out)
76
+
77
+ test.run do |client|
78
+ client.execute(["ls", "iamnothere"])
79
+
80
+ expect(client.exit_code).to eq(2)
81
+ expect(client.out).to eq("")
82
+ expect(client.err).to eq("ls: cannot access iamnothere: No such file or directory\n")
83
+ end
84
+ end
70
85
  end
@@ -11,11 +11,11 @@ describe "hello world" do
11
11
 
12
12
  test.run do |client|
13
13
  sleep 2
14
- client.execute(["curl", "server/hello"])
14
+ client.execute(["curl", "-s", "server/hello"])
15
15
 
16
16
  expect(client.exit_code).to eq(0)
17
17
  expect(client.out).to eq("world\n")
18
- expect(client.err.empty?).to be(true)
18
+ expect(client.err).to eq("")
19
19
  end
20
20
  end
21
21
  end
@@ -31,19 +31,19 @@ describe "hello world" do
31
31
  end
32
32
 
33
33
  it "answers once" do
34
- @client.execute(["curl", "server/hello"])
34
+ @client.execute(["curl", "-s", "server/hello"])
35
35
 
36
36
  expect(@client.exit_code).to eq(0)
37
37
  expect(@client.out).to eq("world\n")
38
- expect(@client.err.empty?).to be(true)
38
+ expect(@client.err).to eq("")
39
39
  end
40
40
 
41
41
  it "answers twice" do
42
- @client.execute(["curl", "server/hello"])
42
+ @client.execute(["curl", "-s", "server/hello"])
43
43
 
44
44
  expect(@client.exit_code).to eq(0)
45
45
  expect(@client.out).to eq("world\n")
46
- expect(@client.err.empty?).to be(true)
46
+ expect(@client.err).to eq("")
47
47
  end
48
48
 
49
49
  after(:all) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpotemkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cornelius Schumacher