features/support/env.rb in nexus_cli-1.0.2 vs features/support/env.rb in nexus_cli-2.0.0

- old
+ new

@@ -1,9 +1,8 @@ -require 'aruba/cucumber' -$:.push "#{File.dirname(__FILE__)}/../../lib/" -require 'nexus_cli' -require 'rspec' +require 'rubygems' +require 'bundler' +require 'spork' module ArubaOverrides def detect_ruby(cmd) processor, platform, *rest = RUBY_PLATFORM.split("-") if platform =~ /w32$/ && cmd =~ /^nexus-cli / @@ -12,44 +11,54 @@ "#{cmd}" end end end -World(ArubaOverrides) +Spork.prefork do + require 'aruba/cucumber' + require 'nexus_cli' + require 'rspec' -Before do - @aruba_timeout_seconds = 10 -end + World(ArubaOverrides) -def get_overrides_string - @overrides_string ||= "url:http://localhost:8081/nexus repository:releases username:admin password:admin123" -end + Before do + @aruba_timeout_seconds = 10 + end -def get_overrides - @overrides ||= {'url' => 'http://localhost:8081/nexus', 'repository' => 'releases', 'username' => 'admin', 'password' => 'admin123'} -end + def get_overrides_string + @overrides_string ||= "url:http://localhost:8081/nexus repository:releases username:admin password:admin123" + end -def create_step_overrides(overrides) - overrides_hash = overrides.split(" ").inject({}) do |overrides_hash, override| - key, value = override.split(":") - overrides_hash[key] = value - overrides_hash + def get_overrides + @overrides ||= {'url' => 'http://localhost:8081/nexus', 'repository' => 'releases', 'username' => 'admin', 'password' => 'admin123'} end - step_overrides = get_overrides.merge(overrides_hash) - step_overrides.to_a.inject("") do |overrides_string, pair| - overrides_string << pair.join(":") - overrides_string << " " + def create_step_overrides(overrides) + overrides_hash = overrides.split(" ").inject({}) do |overrides_hash, override| + key, value = override.split(":") + overrides_hash[key] = value + overrides_hash + end + + step_overrides = get_overrides.merge(overrides_hash) + step_overrides.to_a.inject("") do |overrides_string, pair| + overrides_string << pair.join(":") + overrides_string << " " + end end -end -def temp_dir - @tmpdir ||= Dir.mktmpdir -end + def temp_dir + @tmpdir ||= Dir.mktmpdir + end -def nexus_remote - @nexus_remote ||= NexusCli::Factory.create(get_overrides) + def nexus_remote + @nexus_remote ||= NexusCli::RemoteFactory.create(get_overrides) + end + + at_exit do + FileUtils.rm_rf(temp_dir) + end end -at_exit do - FileUtils.rm_rf(temp_dir) -end \ No newline at end of file +Spork.each_run do + require 'nexus_cli' +end