From 86e4251840039b180ce3caefc5353be7da0f554a Mon Sep 17 00:00:00 2001 From: David Dollar Date: Tue, 4 Oct 2011 11:30:28 -0400 Subject: [PATCH] add ability to test full comamnd line --- spec/foreman/cli_spec.rb | 9 +++++++++ spec/spec_helper.rb | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/spec/foreman/cli_spec.rb b/spec/foreman/cli_spec.rb index 7663a12..2250d08 100644 --- a/spec/foreman/cli_spec.rb +++ b/spec/foreman/cli_spec.rb @@ -26,6 +26,15 @@ describe "Foreman::CLI" do end describe "export" do + describe "options" do + it "respects --env" do + write_procfile + write_env("envfile") + mock.instance_of(Foreman::Export::Upstart).export("/upstart", { "env" => "envfile" }) + foreman %{ export upstart /upstart --env envfile } + end + end + describe "with a non-existent Procfile" do it "prints an error" do mock_error(subject, "Procfile does not exist.") do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0e22f50..c9061e9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,10 @@ def mock_error(subject, message) end end +def foreman(args) + Foreman::CLI.start(args.split(" ")) +end + def mock_exit(&block) block.should raise_error(SystemExit) end @@ -33,6 +37,12 @@ def write_procfile(procfile="Procfile") File.expand_path(procfile) end +def write_env(env=".env") + File.open(env, "w") do |file| + file.puts "FOO=bar" + end +end + def load_export_templates_into_fakefs(type) FakeFS.deactivate! files = Dir[File.expand_path("../../data/export/#{type}/**", __FILE__)].inject({}) do |hash, file|