gusto 1.0.0.beta8 → 1.0.0.beta9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d17eea0ab54967209a74af0bc7e018cd4131be5
4
- data.tar.gz: 5528ecb8ec2a199eecec326defd2466b56be529b
3
+ metadata.gz: a4401a2967b016a74b76bc70b3c81e299f04436a
4
+ data.tar.gz: a266269b65fdbd960acd872992133bcdb65c135d
5
5
  SHA512:
6
- metadata.gz: 679de6ad1176a1b96a8719797e512447404be443423e567df9a3626cb6e7ba441c40bb939dc7cc3b47f0de9b4b7f4d4bb28c1af4b920a05b3489a1619831b861
7
- data.tar.gz: 0938a1f216db53bcffbff44addc396d6a4a54af8a302c747d6691689dc8dac23da44076686db917c45954872eae4ffc5bb62a1dc606477b47a62a258d7ab016e
6
+ metadata.gz: 1bb1ec2b810205bbd1fb371d137ccae69951315a66b6260fa5f33ada1cdadaa3539f0ca9f763d3ed2d75910dc44ddb5ad0fe292a1854887d2c96355731a866ee
7
+ data.tar.gz: 59a1f8d9caa50163d5bd8925217feffe97b6055fcfe2e221d247eb58b0deab0d13cc376c871591cd1828775a66e8bf2cddc407de33b35c3ac27f6ea0085c80d7
@@ -3,11 +3,7 @@ class window.HtmlReport
3
3
  @element = element
4
4
 
5
5
  run: ->
6
- root = new Spec.Suite()
7
- for suite in Spec.suites
8
- root.add suite
9
-
10
- @report = root.run([])
6
+ @report = (new Spec.RootSuite()).run()
11
7
  @element.innerHTML = @html()
12
8
 
13
9
  html: ->
@@ -0,0 +1,8 @@
1
+ class window.Spec.RootSuite extends window.Spec.Suite
2
+ constructor: ->
3
+ super()
4
+ for suite in Spec.suites
5
+ @add suite
6
+
7
+ run: ->
8
+ super []
data/lib/Spec.coffee CHANGED
@@ -1,6 +1,7 @@
1
1
  #= require Spec/Util
2
2
  #= require Spec/Test
3
3
  #= require Spec/Suite
4
+ #= require Spec/RootSuite
4
5
  #= require Spec/Report
5
6
  #= require Spec/ObjectDSL
6
7
  #= require Spec/DSL
@@ -0,0 +1,74 @@
1
+ module Gusto
2
+ class CliRenderer
3
+ PASSED = 0
4
+ PENDING = 1
5
+ FAILED = 2
6
+
7
+ attr :root_report
8
+
9
+ def initialize(root_report)
10
+ @root_report = root_report
11
+ end
12
+
13
+ def render
14
+ [body, footer].compact.reject(&:empty?).join("\n\n")
15
+ end
16
+
17
+ private
18
+
19
+ def body
20
+ root_report['subreports'].map do |subreport|
21
+ report_and_subreport_results subreport
22
+ end.flatten.join "\n"
23
+ end
24
+
25
+ def report_and_subreport_results(report)
26
+ [report_result(report)] + report['subreports'].map do |subreport|
27
+ indented_report_and_subreport_results(subreport)
28
+ end.flatten
29
+ end
30
+
31
+ def indented_report_and_subreport_results(report)
32
+ report_and_subreport_results(report).map do |result|
33
+ " #{result}"
34
+ end
35
+ end
36
+
37
+ def report_result(report)
38
+ result_color report['status'], report['title']
39
+ end
40
+
41
+ def footer
42
+ result_color root_report['status'], "#{total} total, #{passed} passed, #{pending} pending, #{failed} failed"
43
+ end
44
+
45
+ def total
46
+ root_report['counts'].inject(0, &:+)
47
+ end
48
+
49
+ def passed
50
+ root_report['counts'][PASSED]
51
+ end
52
+
53
+ def pending
54
+ root_report['counts'][PENDING]
55
+ end
56
+
57
+ def failed
58
+ root_report['counts'][FAILED]
59
+ end
60
+
61
+ def result_color(result, string)
62
+ case result
63
+ when PASSED
64
+ "\e[32m#{string}\e[0m"
65
+ when PENDING
66
+ "\e[33m#{string}\e[0m"
67
+ when FAILED
68
+ "\e[31m#{string}\e[0m"
69
+ else
70
+ string
71
+ end
72
+ end
73
+ end
74
+ end
data/lib/gusto/server.rb CHANGED
@@ -59,6 +59,7 @@ module Gusto
59
59
  if params[:filter]
60
60
  @scripts = @scripts.select{|file| file.downcase.include? params[:filter].downcase}
61
61
  end
62
+ @headless = params[:headless]
62
63
  render :slim, :index
63
64
  end
64
65
  end
data/lib/gusto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gusto
2
- VERSION = "1.0.0.beta8"
2
+ VERSION = "1.0.0.beta9"
3
3
  end
data/lib/gusto.rb CHANGED
@@ -7,10 +7,15 @@ require 'rack'
7
7
  require 'json'
8
8
  require File.join(File.dirname(__FILE__), 'gusto', 'version')
9
9
 
10
+
10
11
  module Gusto
11
12
  autoload :Configuration, File.join(File.dirname(__FILE__), 'gusto', 'configuration')
12
13
  autoload :Server, File.join(File.dirname(__FILE__), 'gusto', 'server')
13
14
  autoload :Sprockets, File.join(File.dirname(__FILE__), 'gusto', 'sprockets')
15
+ autoload :CliRenderer, File.join(File.dirname(__FILE__), 'gusto', 'cli_renderer')
16
+
17
+ HEADLESS_RUNNER_PATH = File.realpath(
18
+ File.join(File.dirname(__FILE__), '..', 'phantom', 'headless_runner.js'))
14
19
 
15
20
  class << self
16
21
  def root
@@ -33,35 +38,36 @@ module Gusto
33
38
 
34
39
  def cli
35
40
  trap_sigint
36
- spawn_server
37
- result = run_suite
41
+ spawn_server(quiet: true)
42
+ result = run_suite?
38
43
  shut_down(result ? 0 : 1)
39
44
  end
40
45
 
41
46
  def autotest
42
47
  trap_sigint
43
48
  spawn_server
44
- run_suite
49
+ run_suite?
45
50
  watch_for_changes
46
51
  Process.waitall
47
52
  end
48
53
 
49
- def spawn_server
50
- @server = Process.fork{ $0 = 'gusto server'; Server.start }
54
+ def spawn_server(options={})
55
+ @server = Process.fork do
56
+ if options[:quiet]
57
+ $stdout.reopen "/dev/null", "w"
58
+ $stderr.reopen "/dev/null", "w"
59
+ end
60
+ $0 = 'gusto server'
61
+ Server.start
62
+ end
51
63
  wait_for_server_at(root_url)
52
64
  end
53
65
 
54
- def run_suite
55
- if @browser
56
- @browser.navigate.refresh
57
- else
58
- require 'selenium/webdriver'
59
- @browser = Selenium::WebDriver.for :firefox, profile: Selenium::WebDriver::Firefox::Profile.new
60
- @browser.get "#{root_url}#terminal"
61
- end
62
- result = @browser[css: '.results'].text
63
- puts result
64
- !!result.match('passed, 0 failed')
66
+ def run_suite?
67
+ json = `phantomjs #{Shellwords.escape HEADLESS_RUNNER_PATH} #{Configuration.port}`
68
+ report = JSON.parse json
69
+ puts CliRenderer.new(report).render
70
+ report['status'] != 2
65
71
  end
66
72
 
67
73
  def watch_for_changes
@@ -93,7 +99,7 @@ module Gusto
93
99
  private
94
100
 
95
101
  def wait_for_server_at(url)
96
- page = Net::HTTP.get URI.parse(url)
102
+ Net::HTTP.get URI.parse(url)
97
103
  rescue Errno::ECONNREFUSED
98
104
  sleep 1
99
105
  retry
data/views/index.slim CHANGED
@@ -11,8 +11,9 @@ head
11
11
  == javascript_tag(script) + "\n"
12
12
 
13
13
  body
14
- javascript:
15
- $(function() {
16
- window.report = new HtmlReport(document.body);
17
- report.run();
18
- });
14
+ - unless @headless
15
+ javascript:
16
+ $(function() {
17
+ window.report = new HtmlReport(document.body);
18
+ report.run();
19
+ });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gusto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta8
4
+ version: 1.0.0.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Cohen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-script
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: selenium-webdriver
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: listen
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +142,7 @@ files:
156
142
  - lib/gusto/configuration.rb
157
143
  - lib/gusto/version.rb
158
144
  - lib/gusto/server.rb
145
+ - lib/gusto/cli_renderer.rb
159
146
  - lib/gusto/runner.rb
160
147
  - lib/Spec/Matchers.coffee
161
148
  - lib/Spec/Mock.coffee
@@ -165,12 +152,12 @@ files:
165
152
  - lib/Spec/DSL.coffee
166
153
  - lib/Spec/Report.coffee
167
154
  - lib/Spec/Test.coffee
155
+ - lib/Spec/RootSuite.coffee
168
156
  - lib/Spec/Util.coffee
169
157
  - lib/Spec/Suite.coffee
170
158
  - lib/Spec/DelayedExpectation.coffee
171
159
  - public/jsdiff.js
172
160
  - public/ie.js
173
- - public/jquery-1.10.2.js
174
161
  - public/jquery-1.5.2.js
175
162
  - public/stacktrace.js
176
163
  - views/index.slim