Sha256: 0cff999c56efbc2e77ef10fc018b6f3367b22d0f3162d3f83d6d8d6e6f7875bc

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'capybara'
require 'capybara/poltergeist'
require 'launchy'

require_relative './web_application'
require_relative './suite'

# Set the default_wait_time to something reasonable for the entire length of
# the test suite to run. This should probably eventually be something
# configurable because these could break for people with long running test
# suites.
Capybara.default_wait_time = 120 # 2 mins

module Snapdragon
  class CliApplication
    def initialize(options, paths)
      @suite = Snapdragon::Suite.new(options, paths)
    end

    def run
      session = Capybara::Session.new(:poltergeist, Snapdragon::WebApplication.new(nil, @suite))
      if @suite.filtered?
        session.visit("/run?spec=#{@suite.spec_query_param}")
      else
        session.visit("/run")
      end
      session.find("#testscomplete")
      return 0
    end

    def serve
      server = Capybara::Server.new(Snapdragon::WebApplication.new(nil, @suite), 9292)
      server.boot
      if @suite.filtered?
        Launchy.open("http://localhost:9292/run?spec=#{@suite.spec_query_param}")
      else
        Launchy.open('http://localhost:9292/run')
      end
      trap('SIGINT') { puts "Shutting down..."; exit 0 }
      sleep
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
snapdragon-3.0.0 lib/snapdragon/cli_application.rb
snapdragon-2.0.0 lib/snapdragon/cli_application.rb
snapdragon-1.0.0 lib/snapdragon/cli_application.rb
snapdragon-0.2.0 lib/snapdragon/cli_application.rb
snapdragon-0.1.12 lib/snapdragon/cli_application.rb
snapdragon-0.1.11 lib/snapdragon/cli_application.rb
snapdragon-0.1.10 lib/snapdragon/cli_application.rb