Sha256: 33e22b8205a36f9c033536287b802436da89cef53419f42c3c2e93272f2cf3cb

Contents?: true

Size: 939 Bytes

Versions: 4

Compression:

Stored size: 939 Bytes

Contents

require 'yaml'
require 'open3'

module WorldHelpers
  def fake_start_rest_assured(options)
    rest_assured_exec = File.expand_path '../../../bin/rest-assured', __FILE__
    code = File.read rest_assured_exec

    code.sub!(/(.*)/, "\\1\nENV['RACK_ENV'] = 'production'")
    code.sub!(/require 'rest-assured\/application'/, '')
    code.sub!(/RestAssured::Application.run!.*/m, 'puts AppConfig.to_yaml')

    new_exec = "#{rest_assured_exec}_temp"
    File.open(new_exec, 'w') do |file|
      file.write code
    end

    `chmod +x #{new_exec}`

    # this is 1.9.X version. So much more useful than 1.8 (uncommented). Sigh...
    #config_yaml, stderr_str, status = Open3.capture3({'RACK_ENV' => 'production'}, new_exec, *options.split(' '))
    config_yaml = nil
    Open3.popen3(new_exec, *options.split(' ')) do |stdin, stdout, stderr|
      config_yaml = stdout.read
    end

    `rm #{new_exec}`

    YAML.load(config_yaml)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rest-assured-2.0.0 features/support/world_helpers.rb
rest-assured-1.2.2 features/support/world_helpers.rb
rest-assured-1.2.1 features/support/world_helpers.rb
rest-assured-1.2.0 features/support/world_helpers.rb