shell_mock 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/shell_mock/command_stub.rb +31 -2
- data/lib/shell_mock/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25b8d6ab592753360667373eb0864fcdf8717299
|
4
|
+
data.tar.gz: c6927a9111c84a6cfb60354ea7538694901e56eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cada1b891f0d799db477929e60991353e27d9b6e289ee9b781962b1f8bcba49f0f6c25347f00f2710c8ca4808025ea72a7aeea5a50765f6a1ac0c49d3353bd4f
|
7
|
+
data.tar.gz: dcc0f0a6a7c59f6bf7067c08553d36db785ec0f6165bfeaef623e40487993190d2e6b27552ceaea38e7d5cd5242c5225407c31a14195c2cf84c1a950ffe78448
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'shell_mock/call_verifier'
|
2
|
+
require 'shell_mock/stub_registry'
|
2
3
|
|
3
4
|
module ShellMock
|
4
5
|
class CommandStub
|
5
|
-
attr_reader :command, :expected_output, :exitstatus, :env, :options, :side_effect
|
6
|
+
attr_reader :command, :expected_output, :exitstatus, :env, :options, :side_effect, :writer
|
6
7
|
|
7
8
|
def initialize(command)
|
8
9
|
@command = command
|
@@ -10,6 +11,8 @@ module ShellMock
|
|
10
11
|
@options = {}
|
11
12
|
@side_effect = proc {}
|
12
13
|
@exitstatus = 0
|
14
|
+
|
15
|
+
@reader, @writer = IO.pipe
|
13
16
|
end
|
14
17
|
|
15
18
|
def with_env(env)
|
@@ -39,10 +42,36 @@ module ShellMock
|
|
39
42
|
|
40
43
|
def calls
|
41
44
|
@calls ||= []
|
45
|
+
|
46
|
+
marshaled_signatures.each do |marshaled_signature|
|
47
|
+
@calls << Marshal.load(marshaled_signature)
|
48
|
+
end
|
49
|
+
|
50
|
+
@calls
|
42
51
|
end
|
43
52
|
|
44
53
|
def called_with(env, command, options)
|
45
|
-
|
54
|
+
signature = Marshal.dump([env, command, options])
|
55
|
+
|
56
|
+
writer.puts(signature)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
attr_reader :reader
|
62
|
+
|
63
|
+
def marshaled_signatures
|
64
|
+
messages = ""
|
65
|
+
|
66
|
+
loop do
|
67
|
+
begin
|
68
|
+
messages += reader.read_nonblock(1)
|
69
|
+
rescue IO::WaitReadable
|
70
|
+
break
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
messages.split("\n")
|
46
75
|
end
|
47
76
|
end
|
48
77
|
end
|
data/lib/shell_mock/version.rb
CHANGED