cf 0.6.1.rc4 → 0.6.1.rc5
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.
- data/lib/cf/cli.rb +1 -1
- data/lib/cf/cli/space/base.rb +5 -3
- data/lib/cf/cli/space/create.rb +6 -19
- data/lib/cf/cli/space/rename.rb +0 -1
- data/lib/cf/cli/space/space.rb +1 -2
- data/lib/cf/cli/space/spaces.rb +1 -1
- data/lib/cf/cli/space/switch.rb +3 -1
- data/lib/cf/version.rb +1 -1
- data/spec/cf/cli/space/base_spec.rb +42 -0
- data/spec/cf/cli/space/create_spec.rb +1 -41
- data/spec/cf/cli/space/rename_spec.rb +1 -10
- data/spec/cf/cli/space/space_spec.rb +57 -0
- data/spec/cf/cli/space/spaces_spec.rb +2 -10
- data/spec/cf/cli/space/switch_space_spec.rb +1 -11
- data/spec/cf/cli_spec.rb +1 -1
- data/spec/features/account_lifecycle_spec.rb +8 -8
- data/spec/features/login_spec.rb +4 -5
- data/spec/features/push_flow_spec.rb +7 -8
- data/spec/features/switching_targets_spec.rb +8 -10
- data/spec/spec_helper.rb +2 -7
- data/spec/support/cli_helper.rb +2 -2
- metadata +23 -19
- data/spec/assets/specker_runner/specker_runner_input.rb +0 -6
- data/spec/assets/specker_runner/specker_runner_pause.rb +0 -5
- data/spec/console_app_specker/console_app_specker_matchers_spec.rb +0 -173
- data/spec/console_app_specker/specker_runner_spec.rb +0 -167
- data/spec/support/console_app_specker_matchers.rb +0 -86
- data/spec/support/shared_examples/populate_organization.rb +0 -6
- data/spec/support/specker_runner.rb +0 -80
- data/spec/support/tracking_expector.rb +0 -71
@@ -1,167 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SpeckerRunner, :ruby19 => true do
|
4
|
-
def asset(file)
|
5
|
-
File.expand_path("../../assets/specker_runner/#{file}", __FILE__)
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:timeout) { 1 }
|
9
|
-
|
10
|
-
describe "running a command" do
|
11
|
-
let(:file) do
|
12
|
-
file = Tempfile.new('test-specker-runner')
|
13
|
-
sleep 1 # wait one second to make sure touching the file does something measurable
|
14
|
-
file
|
15
|
-
end
|
16
|
-
|
17
|
-
after { file.unlink }
|
18
|
-
|
19
|
-
it "runs a command" do
|
20
|
-
run("touch -a #{file.path}") do |runner|
|
21
|
-
runner.wait_for_exit
|
22
|
-
file.stat.atime.should > file.stat.mtime
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#expect" do
|
28
|
-
context "when the expected output shows up" do
|
29
|
-
it "returns a truthy value" do
|
30
|
-
run("echo -n foo") do |runner|
|
31
|
-
expect(runner.expect('foo')).to be_true
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when the expected output never shows up" do
|
37
|
-
it "returns nil" do
|
38
|
-
run("echo the spanish inquisition") do |runner|
|
39
|
-
expect(runner.expect("something else", 0.5)).to be_nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "when the output eventually shows up" do
|
45
|
-
it "returns a truthy value" do
|
46
|
-
run("ruby #{asset("specker_runner_pause.rb")}") do |runner|
|
47
|
-
expect(runner.expect("finished")).to be_true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "backspace" do
|
53
|
-
it "respects the backspace character" do
|
54
|
-
run("ruby -e 'puts \"foo a\\bbar\"'") do |runner|
|
55
|
-
expect(runner.expect("foo bar")).to be_true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it "does not go beyond the beginning of the line" do
|
60
|
-
run("ruby -e 'print \"foo abc\nx\\b\\bd\"'") do |runner|
|
61
|
-
expect(runner.expect("foo abc\nd")).to be_true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "does not go beyond the beginning of the string" do
|
66
|
-
run("ruby -e 'print \"f\\b\\bbar\"'") do |runner|
|
67
|
-
expect(runner.expect("bar")).to be_true
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
it "leaves backspaced characters in the buffer until they're overwritten" do
|
72
|
-
run("ruby -e 'print \"foo abc\\b\\bd\"'") do |runner|
|
73
|
-
expect(runner.expect("foo adc")).to be_true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "ansi escape sequences" do
|
79
|
-
it "filters ansi color sequences" do
|
80
|
-
run("ruby -e 'puts \"\\e[36mblue\\e[0m thing\"'") do |runner|
|
81
|
-
expect(runner.expect("blue thing")).to be_true
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "expecting multiple branches" do
|
87
|
-
context "and one of them matches" do
|
88
|
-
it "can be passed a hash of values with callbacks, and returns the matched key" do
|
89
|
-
run("echo 1 3") do |runner|
|
90
|
-
branches = {
|
91
|
-
"1" => proc { 1 },
|
92
|
-
"2" => proc { 2 },
|
93
|
-
"3" => proc { 3 }
|
94
|
-
}
|
95
|
-
|
96
|
-
expect(runner.expect(branches)).to eq "1"
|
97
|
-
expect(runner.expect(branches)).to eq "3"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it "calls the matched callback" do
|
102
|
-
callback = mock!
|
103
|
-
run("echo 1 3") do |runner|
|
104
|
-
branches = {
|
105
|
-
"1" => proc { callback }
|
106
|
-
}
|
107
|
-
runner.expect(branches)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "and none of them match" do
|
113
|
-
it "returns nil when none of the branches match" do
|
114
|
-
run("echo not_a_number") do |runner|
|
115
|
-
expect(runner.expect({"1" => proc { 1 }}, timeout)).to be_nil
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "#output" do
|
123
|
-
it "makes the entire command output (so far) available" do
|
124
|
-
run("echo 0 1 2 3") do |runner|
|
125
|
-
runner.expect("1")
|
126
|
-
runner.expect("3")
|
127
|
-
expect(runner.output).to eq "0 1 2 3"
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#send_keys" do
|
134
|
-
it "sends input and expects more output afterward" do
|
135
|
-
run("ruby #{asset("specker_runner_input.rb")}") do |runner|
|
136
|
-
expect(runner.expect("started")).to be_true
|
137
|
-
runner.send_keys("foo")
|
138
|
-
expect(runner.expect("foo")).to be_true
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context "#exit_code" do
|
144
|
-
it "returns the exit code" do
|
145
|
-
run("ruby -e 'exit 42'") do |runner|
|
146
|
-
runner.wait_for_exit
|
147
|
-
expect(runner.exit_code).to eq(42)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context "when the command is still running" do
|
152
|
-
it "waits for the command to exit" do
|
153
|
-
run("sleep 0.5") do |runner|
|
154
|
-
expect(runner.exit_code).to eq(0)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context "#exited?" do
|
161
|
-
it "returns false if the command is still running" do
|
162
|
-
run("sleep 10") do |runner|
|
163
|
-
expect(runner.exited?).to eq false
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
module ConsoleAppSpeckerMatchers
|
2
|
-
class InvalidInputError < StandardError; end
|
3
|
-
|
4
|
-
class ExpectOutputMatcher
|
5
|
-
attr_reader :timeout
|
6
|
-
|
7
|
-
def initialize(expected_output, timeout = 30)
|
8
|
-
@expected_output = expected_output
|
9
|
-
@timeout = timeout
|
10
|
-
end
|
11
|
-
|
12
|
-
def matches?(runner)
|
13
|
-
raise InvalidInputError unless runner.respond_to?(:expect)
|
14
|
-
@matched = runner.expect(@expected_output, @timeout)
|
15
|
-
@full_output = runner.output
|
16
|
-
!!@matched
|
17
|
-
end
|
18
|
-
|
19
|
-
def failure_message
|
20
|
-
if @expected_output.is_a?(Hash)
|
21
|
-
expected_keys = @expected_output.keys.map{|key| "'#{key}'"}.join(', ')
|
22
|
-
"expected one of #{expected_keys} to be printed, but it wasn't. full output:\n#@full_output"
|
23
|
-
else
|
24
|
-
"expected '#{@expected_output}' to be printed, but it wasn't. full output:\n#@full_output"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def negative_failure_message
|
29
|
-
if @expected_output.is_a?(Hash)
|
30
|
-
match = @matched
|
31
|
-
else
|
32
|
-
match = @expected_output
|
33
|
-
end
|
34
|
-
|
35
|
-
"expected '#{match}' to not be printed, but it was. full output:\n#@full_output"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
class ExitCodeMatcher
|
41
|
-
def initialize(expected_code)
|
42
|
-
@expected_code = expected_code
|
43
|
-
end
|
44
|
-
|
45
|
-
def matches?(runner)
|
46
|
-
raise InvalidInputError unless runner.respond_to?(:exit_code)
|
47
|
-
|
48
|
-
begin
|
49
|
-
Timeout.timeout(5) do
|
50
|
-
@actual_code = runner.exit_code
|
51
|
-
end
|
52
|
-
|
53
|
-
@actual_code == @expected_code
|
54
|
-
rescue Timeout::Error
|
55
|
-
@timed_out = true
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def failure_message
|
61
|
-
if @timed_out
|
62
|
-
"expected process to exit with status #@expected_code, but it did not exit within 5 seconds"
|
63
|
-
else
|
64
|
-
"expected process to exit with status #{@expected_code}, but it exited with status #{@actual_code}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def negative_failure_message
|
69
|
-
if @timed_out
|
70
|
-
"expected process to exit with status #@expected_code, but it did not exit within 5 seconds"
|
71
|
-
else
|
72
|
-
"expected process to not exit with status #{@expected_code}, but it did"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def say(expected_output, timeout = 30)
|
78
|
-
ExpectOutputMatcher.new(expected_output, timeout)
|
79
|
-
end
|
80
|
-
|
81
|
-
def have_exited_with(expected_code)
|
82
|
-
ExitCodeMatcher.new(expected_code)
|
83
|
-
end
|
84
|
-
|
85
|
-
alias :exit_with :have_exited_with
|
86
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require "pty"
|
2
|
-
|
3
|
-
class SpeckerRunner
|
4
|
-
def initialize(*args)
|
5
|
-
@stdout, slave = PTY.open
|
6
|
-
system("stty raw", :in => slave)
|
7
|
-
read, @stdin = IO.pipe
|
8
|
-
|
9
|
-
@pid = spawn(*(args.push(:in => read, :out => slave, :err => slave)))
|
10
|
-
|
11
|
-
@expector = TrackingExpector.new(@stdout, ENV["DEBUG_BACON"])
|
12
|
-
|
13
|
-
yield self
|
14
|
-
end
|
15
|
-
|
16
|
-
def expect(matcher, timeout = 30)
|
17
|
-
case matcher
|
18
|
-
when Hash
|
19
|
-
expect_branches(matcher, timeout)
|
20
|
-
else
|
21
|
-
@expector.expect(matcher, timeout)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def send_keys(text_to_send)
|
26
|
-
@stdin.puts(text_to_send)
|
27
|
-
end
|
28
|
-
|
29
|
-
def exit_code
|
30
|
-
return @status if @status
|
31
|
-
|
32
|
-
status = nil
|
33
|
-
Timeout.timeout(5) do
|
34
|
-
_, status = Process.waitpid2(@pid)
|
35
|
-
end
|
36
|
-
|
37
|
-
@status = numeric_exit_code(status)
|
38
|
-
end
|
39
|
-
|
40
|
-
alias_method :wait_for_exit, :exit_code
|
41
|
-
|
42
|
-
def exited?
|
43
|
-
!running?
|
44
|
-
end
|
45
|
-
|
46
|
-
def running?
|
47
|
-
!!Process.getpgid(@pid)
|
48
|
-
end
|
49
|
-
|
50
|
-
def output
|
51
|
-
@expector.output
|
52
|
-
end
|
53
|
-
|
54
|
-
def debug
|
55
|
-
@expector.debug
|
56
|
-
end
|
57
|
-
|
58
|
-
def debug=(x)
|
59
|
-
@expector.debug = x
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def expect_branches(branches, timeout)
|
65
|
-
branch_names = /#{branches.keys.collect { |k| Regexp.quote(k) }.join("|")}/
|
66
|
-
expected = @expector.expect(branch_names, timeout)
|
67
|
-
return unless expected
|
68
|
-
|
69
|
-
data = expected.first.match(/(#{branch_names})$/)
|
70
|
-
matched = data[1]
|
71
|
-
branches[matched].call
|
72
|
-
matched
|
73
|
-
end
|
74
|
-
|
75
|
-
def numeric_exit_code(status)
|
76
|
-
status.exitstatus
|
77
|
-
rescue NoMethodError
|
78
|
-
status
|
79
|
-
end
|
80
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
class TrackingExpector
|
2
|
-
attr_reader :output
|
3
|
-
|
4
|
-
def initialize(out, debug = false)
|
5
|
-
@out = out
|
6
|
-
@debug = debug
|
7
|
-
@unused = ""
|
8
|
-
@output = ""
|
9
|
-
end
|
10
|
-
|
11
|
-
def expect(pattern, timeout = 5)
|
12
|
-
buffer = ''
|
13
|
-
|
14
|
-
case pattern
|
15
|
-
when String
|
16
|
-
pattern = Regexp.new(Regexp.quote(pattern))
|
17
|
-
when Regexp
|
18
|
-
else
|
19
|
-
raise TypeError, "unsupported pattern class: #{pattern.class}"
|
20
|
-
end
|
21
|
-
|
22
|
-
result = nil
|
23
|
-
position = 0
|
24
|
-
@unused ||= ""
|
25
|
-
|
26
|
-
while true
|
27
|
-
if !@unused.empty?
|
28
|
-
c = @unused.slice!(0).chr
|
29
|
-
elsif output_ended?(timeout)
|
30
|
-
@unused = buffer
|
31
|
-
break
|
32
|
-
else
|
33
|
-
c = @out.getc.chr
|
34
|
-
end
|
35
|
-
|
36
|
-
STDOUT.putc c if @debug
|
37
|
-
|
38
|
-
# wear your flip flops
|
39
|
-
unless (c == "\e") .. (c == "m")
|
40
|
-
if c == "\b"
|
41
|
-
if position > 0 && buffer[position - 1] && buffer[position - 1].chr != "\n"
|
42
|
-
position -= 1
|
43
|
-
end
|
44
|
-
else
|
45
|
-
if buffer.size > position
|
46
|
-
buffer[position] = c
|
47
|
-
else
|
48
|
-
buffer << c
|
49
|
-
end
|
50
|
-
|
51
|
-
position += 1
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
if matches = pattern.match(buffer)
|
56
|
-
result = [buffer, *matches.to_a[1..-1]]
|
57
|
-
break
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
@output << buffer
|
62
|
-
|
63
|
-
result
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def output_ended?(timeout)
|
69
|
-
(@out.is_a?(IO) && !IO.select([@out], nil, nil, timeout)) || @out.eof?
|
70
|
-
end
|
71
|
-
end
|