Sha256: 034d2c39bfa7f08c6ba51ea96a897cbbed119cabfa5e6d9b9b0ea269a077a26a

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require 'net/http'

module Signonotron2IntegrationHelpers
  def wait_for_signonotron_to_start
    retries = 0
    url = GDS::SSO::Config.oauth_root_url
    puts "Waiting for signonotron to start at #{url}"
    while ! signonotron_started?(url)
      print '.'
      if retries > 20
        raise "Signonotron is not running at #{url}. Please start with 'bundle exec rake signonotron:start'. Under jenkins this should have been run automatically"
      end
      retries += 1
      sleep 1
    end
    puts "Signonotron is now running at #{url}"
  end

  def signonotron_started?(url)
    uri = URI.parse(url)
    conn = Net::HTTP.start(uri.host, uri.port)
    true
  rescue Errno::ECONNREFUSED
    false
  ensure
    conn.try(:finish)
  end

  def load_signonotron_fixture
    fixtures_path = Pathname.new(File.join(File.dirname(__FILE__), '../fixtures/integration'))
    app = ENV['SIGNONOTRON_VERSION'] == "1" ? "sign-on-o-tron" : "signonotron2"
    path_to_app = Rails.root.join('..','..','tmp',app)

    db = YAML.load_file(fixtures_path + "#{app}_database.yml")['test']
    cmd = "sqlite3 #{path_to_app + db['database']} < #{fixtures_path + "#{app}.sql"}"
    system cmd or raise "Error loading signonotron fixture"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gds-sso-0.6.1 spec/support/signonotron2_integration_helpers.rb
gds-sso-0.6.0 spec/support/signonotron2_integration_helpers.rb
gds-sso-0.5.4 spec/support/signonotron2_integration_helpers.rb
gds-sso-0.5.3 spec/support/signonotron2_integration_helpers.rb
gds-sso-0.5.2 spec/support/signonotron2_integration_helpers.rb
gds-sso-0.5.1 spec/support/signonotron2_integration_helpers.rb