spec/spec_helper.rb in vmc-0.5.0.beta.7 vs spec/spec_helper.rb in vmc-0.5.0.beta.10

- old
+ new

@@ -1,18 +1,28 @@ SPEC_ROOT = File.dirname(__FILE__).freeze require "rspec" require "cfoundry" -require "cfoundry/spec_helper" +require "cfoundry/test_support" require "vmc" +require "vmc/test_support" Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file| require file end RSpec.configure do |c| + c.include Fake::FakeMethods c.mock_with :rr + + c.include VMC::TestSupport::FakeHomeDir + c.include VMC::TestSupport::CommandHelper + c.include VMC::TestSupport::InteractHelper + + c.before do + VMC::CLI.send(:class_variable_set, :@@client, nil) + end end class String def strip_heredoc min = scan(/^[ \t]*(?=\S)/).min @@ -23,23 +33,25 @@ def strip_progress_dots gsub(/\. \x08([\x08\. ]+)/, "... ") end end -def with_output_to(output = StringIO.new) - old_out = $stdout - old_err = $stderr - $stdout = output - $stderr = output - yield output -ensure - $stdout = old_out - $stderr = old_err -end - def name_list(xs) if xs.empty? "none" else xs.collect(&:name).join(", ") end +end + +def invoke_cli(cli, *args) + stub.proxy(cli).invoke.with_any_args + stub(cli.class).new { cli } + cli.invoke(*args) +end + +def stub_output(cli) + stub(cli).print + stub(cli).puts + stub(Interact::Progress::Dots).start! + stub(Interact::Progress::Dots).stop! end