Sha256: 29642bdaabe83ceceb7719052861e09ef4c3273d0de2c6122e6e78080cef9e13
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
require 'capybara' require 'capybara/poltergeist' require 'launchy' require_relative './web_application' require_relative './suite' require_relative './spec_file' require_relative './spec_directory' module Snapdragon class CliApplication def initialize(arguements) @args = arguements @suite = Snapdragon::Suite.new end def run parse_arguements(@args) run_suite return 0 end def serve parse_arguements(@args) server = Capybara::Server.new(Snapdragon::WebApplication.new(nil, @suite), 9292) server.boot Launchy.open('http://localhost:9292/run') trap('SIGINT') { puts "Shutting down..."; exit 0 } sleep end private def parse_arguements(arguements) arguements.each do |arguement| parse_arguement(arguement) end end def parse_arguement(arguement) if is_a_file_path_and_line_number?(arguement) path, line_num_str = arguement.split(':') @suite.add_spec_file(SpecFile.new(path, line_num_str.to_i)) elsif is_a_file_path?(arguement) @suite.add_spec_file(SpecFile.new(arguement)) elsif is_a_directory?(arguement) spec_dir = Snapdragon::SpecDirectory.new(arguement) @suite.add_spec_files(spec_dir.spec_files) end end def is_a_file_path_and_line_number?(arguement) arguement =~ /^[\w\/\-\d]+[s|S]pec\.js:\d+$/ end def is_a_file_path?(arguement) arguement =~ /^[\w\/\-\d]+[s|S]pec\.js$/ end def is_a_directory?(arguement) arguement =~ /^[\w\/\-\d]+$/ end def run_suite 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
snapdragon-0.1.2 | lib/snapdragon/cli_application.rb |
snapdragon-0.1.1 | lib/snapdragon/cli_application.rb |
snapdragon-0.1.0 | lib/snapdragon/cli_application.rb |