jasminerice-runner 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .redcar
6
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jasminerice-runner.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ jasminerice-runner
2
+ ==================
3
+
4
+ Uses capybara to run jasmine specs with jasminerice and rails asset pipeline
5
+
6
+ Usage
7
+ -----
8
+
9
+ Add this to your spec.js:
10
+
11
+ #= require jasminerice_reporter
12
+
13
+ Then, run the rake task
14
+
15
+ rake jasminerice:run
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jasminerice-runner/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jasminerice-runner"
7
+ s.version = Jasminerice::Runner::VERSION
8
+ s.authors = ["Chris Nelson"]
9
+ s.email = ["chris@gaslightsoftware.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{runs jasmine specs using capybara}
12
+ s.description = %q{Adds a rake task to run jasmine specs using capybara}
13
+
14
+ s.rubyforge_project = "jasminerice-runner"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "capybara"
24
+ end
@@ -0,0 +1,23 @@
1
+ class JasminericeReporter
2
+ @failedSpecs = {}
3
+ reportRunnerResults: (runner)->
4
+ @finished = true
5
+ @results = runner.results()
6
+
7
+ reportSpecResults: (spec) ->
8
+ #return if @failed
9
+ @failedSpecs or= {}
10
+ if spec.results().failedCount > 0
11
+ failure = ''
12
+ for expectation in spec.results().getItems()
13
+ if !expectation.passed()
14
+ failure = expectation.message
15
+ @failedSpecs[spec.suite.description] or= {}
16
+ @failedSpecs[spec.suite.description][spec.description] or= []
17
+ @failedSpecs[spec.suite.description][spec.description].push(failure)
18
+ #@failed = true
19
+
20
+
21
+ jQuery ->
22
+ window.jasmineRiceReporter = new JasminericeReporter()
23
+ jasmine.getEnv().addReporter jasmineRiceReporter
@@ -0,0 +1,4 @@
1
+ module Jasminerice
2
+ class JasmineRiceRunnerEngine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,37 @@
1
+ module Jasminerice
2
+ class Runner
3
+ include Capybara::DSL
4
+
5
+ def run
6
+ Capybara.default_driver = :selenium
7
+ visit "/jasmine"
8
+ puts "Running jasmine specs"
9
+ wait_until { page.evaluate_script("window.jasmineRiceReporter.finished")}
10
+ passed = page.evaluate_script("window.jasmineRiceReporter.results.passedCount")
11
+ failed = page.evaluate_script("window.jasmineRiceReporter.results.failedCount")
12
+ total = page.evaluate_script("window.jasmineRiceReporter.results.totalCount")
13
+ failures = page.evaluate_script("window.jasmineRiceReporter.failedSpecs")
14
+ puts "Jasmine results - Passed: #{passed} Failed: #{failed} Total: #{total}"
15
+ if failures.size > 0
16
+ puts 'Jasmine failures: '
17
+ for suiteName,suiteFailures in failures
18
+ puts " " + suiteName + "\n"
19
+ for specName,specFailures in suiteFailures
20
+ puts " " + specName + "\n"
21
+ for specFailure in specFailures
22
+ puts " " + specFailure + "\n"
23
+ end
24
+ end
25
+ puts "\n"
26
+ end
27
+ end
28
+
29
+ if page.evaluate_script("window.jasmineRiceReporter.results.failedCount") == 0
30
+ puts "Jasmine specs passed, yay!"
31
+ else
32
+ raise "Jasmine specs failed"
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Jasminerice
2
+ class Runner
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ namespace :jasminerice do
2
+
3
+ desc "run jasmine specs in jasmine rice"
4
+ task :run => :environment do
5
+ require "capybara/rails"
6
+ require "jasminerice-runner/runner"
7
+ Jasminerice::Runner.new.run
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jasminerice-runner
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Chris Nelson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-02 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: capybara
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Adds a rake task to run jasmine specs using capybara
36
+ email:
37
+ - chris@gaslightsoftware.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README.md
48
+ - Rakefile
49
+ - jasminerice-runner.gemspec
50
+ - lib/assets/javascripts/jasminerice_reporter.js.coffee
51
+ - lib/jasminerice-runner.rb
52
+ - lib/jasminerice-runner/runner.rb
53
+ - lib/jasminerice-runner/version.rb
54
+ - lib/tasks/jasminerice-runner.rake
55
+ has_rdoc: true
56
+ homepage: ""
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project: jasminerice-runner
85
+ rubygems_version: 1.3.7
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: runs jasmine specs using capybara
89
+ test_files: []
90
+