vmc-ng/lib/vmc/spec_helpers.rb in vmc-0.4.0.beta.36 vs vmc-ng/lib/vmc/spec_helpers.rb in vmc-0.4.0.beta.37

- old
+ new

@@ -1,17 +1,19 @@ +require "rspec" + require "cfoundry" require "vmc" require "vmc/spec_helpers/eventlog" require "vmc/spec_helpers/patches" -TARGET = ENV["VMC_TEST_TARGET"] || "http://localhost:8181" -USER = ENV["VMC_TEST_USER"] || "sre@vmware.com" -PASSWORD = ENV["VMC_TEST_PASSWORD"] || "test" - module VMCHelpers + TARGET = ENV["VMC_TEST_TARGET"] || "http://localhost:8181" + USER = ENV["VMC_TEST_USER"] || "sre@vmware.com" + PASSWORD = ENV["VMC_TEST_PASSWORD"] || "test" + def random_str format("%x", rand(1000000)) end def client @@ -102,18 +104,18 @@ main = Thread.current thd = Thread.new do begin - VMC::CLI.new.invoke(command, inputs, given) + VMC::CLI.new.invoke(command, inputs, given, :quiet => true) rescue SystemExit => e unless e.status == 0 raise <<EOF execution failed with status #{e.status}! stdout: -#{$stdout.string.inspect} +#{$stdout.string} stderr: #{$stderr.string} EOF end @@ -193,11 +195,16 @@ @name = name @expected = value end def matches?(log) - @actual = log.wait_for_event(EventLog::GotInput).value + input = log.wait_for_event(EventLog::GotInput) + until input.name == @name + input = log.wait_for_event(EventLog::GotInput) + end + + @actual = input.value @actual == @expected end def failure_message "expected to have input '#@name' as '#@expected', but got '#@actual'" @@ -396,12 +403,15 @@ RSpec.configure do |c| c.include VMCHelpers c.include VMCMatchers c.before(:all) do - VMC::CLI.client = CFoundry::Client.new(TARGET) + VMC::CLI.client = CFoundry::Client.new(VMCHelpers::TARGET) - client.login(:username => USER, :password => PASSWORD) + client.login( + :username => VMCHelpers::USER, + :password => VMCHelpers::PASSWORD) + client.current_organization = client.organizations.first client.current_space = client.current_organization.spaces.first end end