Sha256: 23a4abe1e631359b54fc4a8fa046b68522fff0be2ff2b73d2391340982a93435

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

SPEC_ROOT = File.dirname(__FILE__).freeze

require "rspec"
require "cfoundry"
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
    indent = min ? min.size : 0
    gsub(/^[ \t]{#{indent}}/, '')
  end

  def strip_progress_dots
    gsub(/\.  \x08([\x08\. ]+)/, "... ")
  end
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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vmc-0.5.0.beta.12 spec/spec_helper.rb
vmc-0.5.0.beta.11 spec/spec_helper.rb
vmc-0.5.0.beta.10 spec/spec_helper.rb