Class: Snapdragon::CliApplication

Inherits:
Object
  • Object
show all
Defined in:
lib/snapdragon/cli_application.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, paths) ⇒ CliApplication

Returns a new instance of CliApplication.



16
17
18
# File 'lib/snapdragon/cli_application.rb', line 16

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

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/snapdragon/cli_application.rb', line 20

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

#serveObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/snapdragon/cli_application.rb', line 31

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