forked from heroku/legacy-cli
/
run_spec.rb
69 lines (61 loc) · 2.2 KB
/
run_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require "spec_helper"
require "heroku/command/run"
describe Heroku::Command::Run do
describe "run" do
it "runs a command" do
stub_core.ps_run("myapp", :attach => true, :command => "bin/foo", :ps_env => get_terminal_environment).returns("process" => "run.1", "rendezvous_url" => "rendezvous://s1.runtime.heroku.com:5000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
stub_rendezvous.start { $stdout.puts "output" }
stderr, stdout = execute("run bin/foo")
stderr.should == ""
stdout.should == <<-STDOUT
Running bin/foo attached to terminal... up, run.1
output
STDOUT
end
end
describe "run:detached" do
it "runs a command detached" do
stub_core.ps_run("myapp", :attach => false, :command => "bin/foo").returns("process" => "run.1")
stub_rendezvous.start { $stdout.puts "output" }
stderr, stdout = execute("run:detached bin/foo")
stderr.should == ""
stdout.should == <<-STDOUT
Running bin/foo... up, run.1
Use `heroku logs -p run.1` to view the output.
STDOUT
end
end
describe "run:rake" do
it "runs a rake command" do
stub_core.ps_run("myapp", :attach => true, :command => "rake foo", :ps_env => get_terminal_environment, :type => "rake").returns("rendezvous_url" => "rendezvous://s1.runtime.heroku.com:5000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
stub_rendezvous.start do
$stdout.puts("rake_output")
end
stderr, stdout = execute("run:rake foo")
stderr.should == ""
stdout.should == <<-STDOUT
rake_output
STDOUT
end
it "requires a command" do
lambda { execute "run:rake" }.should fail_command("Usage: heroku rake COMMAND")
end
end
describe "run:console" do
it "runs a console session" do
console = stub(Heroku::Client::ConsoleSession)
stub_core.console.returns(console)
stderr, stdout = execute("run:console")
stderr.should == ""
stdout.should == ""
end
it "runs a console command" do
stub_core.console("myapp", "bash foo").returns("foo_output")
stderr, stdout = execute("run:console bash foo")
stderr.should == ""
stdout.should == <<-STDOUT
foo_output
STDOUT
end
end
end