diff --git a/Rakefile b/Rakefile index a0db94f..4c1b84c 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,18 @@ Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :default => [:spec, 'integration:live'] +task :default => [:credentials, :spec, 'integration:live'] + +task :credentials do + if ENV['TRAVIS_SECURE_ENV_VARS'] == 'false' + puts "Setting vars" + ENV['OS_USERNAME'] = '_RAX_USERNAME_' + ENV['OS_PASSWORD'] = '_RAX_PASSWORD_' + ENV['RS_TENANT_ID'] = '000000' + ENV['RS_CDN_TENANT_NAME'] = '_CDN-TENANT-NAME_' + end + fail "Not all required variables detected" unless ENV['OS_USERNAME'] && ENV['OS_PASSWORD'] && ENV['RS_CDN_TENANT_NAME'] && ENV['RS_TENANT_ID'] +end namespace :integration do desc 'Run the integration tests' @@ -33,9 +44,8 @@ namespace :integration do desc 'Run the integration tests live (no VCR cassettes)' task :live do unless ENV['TRAVIS'] == 'true' && ENV['TRAVIS_SECURE_ENV_VARS'] == 'false' - fail "Not all required variables detected" unless ENV['OS_USERNAME'] && ENV['OS_PASSWORD'] && ENV['RS_CDN_TENANT_NAME'] && ENV['RS_TENANT_ID'] ENV['INTEGRATION_TESTS'] = 'live' Rake::Task['integration:test'].invoke end end -end \ No newline at end of file +end diff --git a/spec/integration/integration_spec.rb b/spec/integration/integration_spec.rb index f7cb827..724466a 100644 --- a/spec/integration/integration_spec.rb +++ b/spec/integration/integration_spec.rb @@ -15,7 +15,7 @@ it 'should list server flavors', :vcr do stdout, stderr, status = knife_capture('rackspace flavor list') - status.should == 0 + status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}" expected_output = { :v1 => """ @@ -50,8 +50,8 @@ } stdout, stderr, status = knife_capture('rackspace image list') - status.should == 0 - stdout = ANSI.unansi stdout + status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}" + stdout = clean_output(stdout) stdout.should match /^ID\s*Name\s*$/ stdout.should include sample_image[api] end @@ -68,7 +68,7 @@ args = %W{rackspace server create -I #{image[api]} -f #{flavor} -N test-node -S test-server} stdout, stderr, status = knife_capture(args) - status.should == 0 + status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}" instance_data = capture_instance_data(stdout, { :name => 'Name', :instance_id => 'Instance ID', @@ -81,7 +81,7 @@ args = %W{rackspace server delete #{instance_data[:instance_id]} -y} stdout, stderr, status = knife_capture(args) - status.should == 0 + status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}" # Need to deal with deleting vs deleted states before we can check this # server_list.should_not match /#{instance_data[:instance_id]}\s*#{instance_data[:name]}\s*#{instance_data[:public_ip]}\s*#{instance_data[:private_ip]}\s*#{flavor}\s*#{image}/ diff --git a/spec/integration_spec_helper.rb b/spec/integration_spec_helper.rb index 977815e..21ac357 100644 --- a/spec/integration_spec_helper.rb +++ b/spec/integration_spec_helper.rb @@ -17,7 +17,7 @@ c.filter_sensitive_data('_RAX_USERNAME_') { Chef::Config[:knife][:rackspace_api_username] } c.filter_sensitive_data('_RAX_PASSWORD_') { Chef::Config[:knife][:rackspace_api_key] } c.filter_sensitive_data('_CDN-TENANT-NAME_') { ENV['RS_CDN_TENANT_NAME'] } - c.filter_sensitive_data('_TENANT-ID_') { ENV['RS_TENANT_ID'] } + c.filter_sensitive_data('000000') { ENV['RS_TENANT_ID'] } c.before_record do |interaction| # Sensitive data @@ -38,6 +38,10 @@ end end + c.before_playback do | interaction | + interaction.filter!('_TENANT-ID_', '0000000') + end + c.default_cassette_options = { # :record => :none, # Ignores cache busting parameters. @@ -62,7 +66,10 @@ def filter_headers(interaction, pattern, placeholder) end def clean_output(output) - ANSI.unansi(output).gsub(/\s+$/,'') + output = ANSI.unansi(output) + output.gsub!(/\s+$/,'') + output.gsub!("\e[0G", '') + output end RSpec::Matchers.define :match_output do |expected_output|