jasminerice-runner 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -22,4 +22,16 @@ To switch drivers, in a config/initializer
|
|
22
22
|
|
23
23
|
Jasminerice::Runner.capybara_driver = :webkit
|
24
24
|
|
25
|
-
Default driver is :selenium
|
25
|
+
Default driver is :selenium
|
26
|
+
|
27
|
+
Using Multiple Jasmine Environments
|
28
|
+
-----------------------------------
|
29
|
+
|
30
|
+
If your app has multiple jasmine environments, you can specify the runner
|
31
|
+
to only run jasmine tests for that environment. Adding an environment will
|
32
|
+
run the file "#{ENVIRONMENT}_spec.js". The default spec file (spec.js) will be run
|
33
|
+
if no environment is specified.
|
34
|
+
|
35
|
+
For example, if you wanted to run all specs in admin_spec.js the rake task would be:
|
36
|
+
|
37
|
+
rake jasminerice:run["admin"]
|
@@ -21,5 +21,5 @@ class JasminericeReporter
|
|
21
21
|
# when capybara hits us before the onload function has run
|
22
22
|
window.jasmineRiceReporter = new JasminericeReporter()
|
23
23
|
|
24
|
-
|
24
|
+
document.addEventListener 'DOMContentLoaded', ->
|
25
25
|
jasmine.getEnv().addReporter window.jasmineRiceReporter
|
@@ -1,42 +1,85 @@
|
|
1
1
|
module Jasminerice
|
2
2
|
class Runner
|
3
|
-
|
4
3
|
include Capybara::DSL
|
5
|
-
|
4
|
+
|
5
|
+
def initialize(environment)
|
6
|
+
@environment = environment
|
7
|
+
end
|
8
|
+
|
6
9
|
def capybara_driver
|
7
10
|
self.class.capybara_driver || :selenium
|
8
11
|
end
|
9
|
-
|
12
|
+
|
10
13
|
def run
|
11
14
|
Capybara.default_driver = capybara_driver
|
12
|
-
visit
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
failures =
|
19
|
-
|
20
|
-
if failures.size
|
21
|
-
puts 'Jasmine failures: '
|
22
|
-
for suiteName,suiteFailures in failures
|
23
|
-
puts " " + suiteName + "\n"
|
24
|
-
for specName,specFailures in suiteFailures
|
25
|
-
puts " " + specName + "\n"
|
26
|
-
for specFailure in specFailures
|
27
|
-
puts " " + specFailure + "\n"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
puts "\n"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
if page.evaluate_script("window.jasmineRiceReporter.results.failedCount") == 0
|
15
|
+
visit jasmine_url
|
16
|
+
print "Running jasmine specs"
|
17
|
+
|
18
|
+
wait_for_finished
|
19
|
+
results = get_results
|
20
|
+
puts "Jasmine results - Passed: #{results[:passed]} Failed: #{results[:failed]} Total: #{results[:total]}"
|
21
|
+
failures = results[:failures]
|
22
|
+
|
23
|
+
if failures.size == 0
|
35
24
|
puts "Jasmine specs passed, yay!"
|
36
25
|
else
|
26
|
+
report_failures(failures)
|
37
27
|
raise "Jasmine specs failed"
|
38
28
|
end
|
39
29
|
end
|
40
|
-
|
30
|
+
|
31
|
+
def jasmine_url
|
32
|
+
url = "/jasmine"
|
33
|
+
if @environment.present?
|
34
|
+
url += "?environment=#{@environment}"
|
35
|
+
end
|
36
|
+
|
37
|
+
url
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_results
|
41
|
+
{
|
42
|
+
passed: page.evaluate_script("window.jasmineRiceReporter.results.passedCount"),
|
43
|
+
failed: page.evaluate_script("window.jasmineRiceReporter.results.failedCount"),
|
44
|
+
total: page.evaluate_script("window.jasmineRiceReporter.results.totalCount"),
|
45
|
+
failures: page.evaluate_script("window.jasmineRiceReporter.failedSpecs")
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def report_failures(failures)
|
50
|
+
puts 'Jasmine failures: '
|
51
|
+
for suiteName,suiteFailures in failures
|
52
|
+
puts " " + suiteName + "\n"
|
53
|
+
for specName,specFailures in suiteFailures
|
54
|
+
puts " " + specName + "\n"
|
55
|
+
for specFailure in specFailures
|
56
|
+
puts " " + specFailure + "\n"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
puts "\n"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def wait_for_finished
|
64
|
+
reporter = page.evaluate_script("window.jasmineRiceReporter")
|
65
|
+
if reporter.nil?
|
66
|
+
if @environment.present?
|
67
|
+
filename = "#{@environment}_spec.js"
|
68
|
+
else
|
69
|
+
filename = "spec.js"
|
70
|
+
end
|
71
|
+
puts "\njasmineRiceReporter not defined! Check your configuration to make\n" +
|
72
|
+
"sure that #{filename} exists and that jasminerice_reporter is included."
|
73
|
+
raise "Reporter not found"
|
74
|
+
end
|
75
|
+
|
76
|
+
start = Time.now
|
77
|
+
while true
|
78
|
+
break if page.evaluate_script("window.jasmineRiceReporter.finished")
|
79
|
+
sleep 1
|
80
|
+
print "."
|
81
|
+
end
|
82
|
+
print "\n"
|
83
|
+
end
|
41
84
|
end
|
42
|
-
end
|
85
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
namespace :jasminerice do
|
2
|
-
|
2
|
+
|
3
3
|
desc "run jasmine specs in jasmine rice"
|
4
|
-
task :run => :environment do
|
4
|
+
task :run, [:jasmine_environment] => :environment do |t, args|
|
5
5
|
require "capybara/rails"
|
6
6
|
require "jasminerice-runner/runner"
|
7
|
-
Jasminerice::Runner.new
|
7
|
+
runner = Jasminerice::Runner.new(args[:jasmine_environment])
|
8
|
+
runner.run
|
8
9
|
end
|
9
|
-
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasminerice-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Nelson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-07 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|