jasminecoffee 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6afa4079d8c3e4cca9e73bba8095e5fd8b4d528f
4
+ data.tar.gz: 8529109d6407875f3f0b2e41a74b7da00dc5520f
5
+ SHA512:
6
+ metadata.gz: 731ad336b9138e9cfb6f08da298617075cdba5753a50c20b38ab9648dbf5eb7bcbb0bf69f7895fdd672ce41d5e3416368dc61368cce4b47c3ed73a74c774e597
7
+ data.tar.gz: 6af863e58b6f7fd87290fff382431948a6b704e77dfede6daaaba18ac3cea166f40fb852ab4a15f8fa27c6b72c9a614af93b2cf587fccd482575223ecd3a3a95
data/MIT.LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Brad Phelan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ JasmineCoffee
2
+ ===========
3
+
4
+
5
+ ## Installation
6
+
7
+ This gem has been tested and run with Rails 3.2.
8
+
9
+ Just include it in your `Gemfile`:
10
+
11
+ ```ruby
12
+ group :development, :test do
13
+ gem "jasminecoffee"
14
+ end
15
+ ```
16
+
17
+ ## Author
18
+
19
+ * Brendan Keogh)
@@ -0,0 +1,19 @@
1
+ #=require jquery-2.1.3
2
+ #=require jasmine
3
+ #=require jasmine-html
4
+ #=require boot
5
+ #=require jasmine-jquery-2.0.5
6
+
7
+ (->
8
+
9
+ jasmine.getFixtures().fixturesPath = 'jasmine/fixtures'
10
+ jasmine.getStyleFixtures().fixturesPath = 'jasmine/fixtures'
11
+ jasmine.getJSONFixtures().fixturesPath = 'jasmine/fixtures/json'
12
+
13
+ jasmine.coffee = {}
14
+ jasmine.coffee.autoExecute = true
15
+
16
+ currentWindowOnload = window.onload
17
+ window.onload = ->
18
+ currentWindowOnload() if currentWindowOnload
19
+ )()
@@ -0,0 +1,4 @@
1
+ module JasmineCoffee
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,22 @@
1
+ module JasmineCoffee
2
+ class SpecController < Jasminerice::ApplicationController
3
+ warn "Using JasmineCoffee::HelperMethods is deprecated and will be removed in a future release,"\
4
+ "please use Jasminerice::SpecHelper to define your helpers in the future" if defined?(JasmineCoffee::HelperMethods)
5
+
6
+ helper JasmineCoffee::HelperMethods rescue nil
7
+ helper JasmineCoffee::SpecHelper rescue nil
8
+
9
+ before_filter { prepend_view_path Rails.root.to_s }
10
+
11
+ layout false
12
+
13
+ def index
14
+ @specsuite = params[:suite].try(:concat, "_spec") || "spec"
15
+ @asset_options = %w(true false).include?(params[:debug]) ? { :debug => params[:debug] == 'true' } : {}
16
+ end
17
+
18
+ def fixtures
19
+ render "#{JasmineCoffee.fixture_path}/#{params[:filename]}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ module JasmineCoffee
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Jasmine Spec Runner</title>
5
+ <%= stylesheet_link_tag "jasmine" %>
6
+ <%= stylesheet_link_tag "spec", @asset_options.clone %>
7
+ <%= javascript_include_tag "jasminecoffee" %>
8
+ <%= javascript_include_tag @specsuite, @asset_options.clone %>
9
+ <%= csrf_meta_tags %>
10
+ </head>
11
+ <body></body>
12
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ JasmineCoffee::Engine.routes.draw do
2
+ resources :spec, :controller => 'spec', :only => [:index] do
3
+ get "fixtures/*filename", :action => :fixtures
4
+ end
5
+ get "fixtures/*filename", :to => "spec#fixtures"
6
+ get "/(:suite)", :to => "spec#index"
7
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails'
2
+ if ::Rails.version >= '3.1'
3
+ module JasmineCoffee
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def copy_files
9
+ copy_file 'jasminecoffee.rb', 'config/initializers/jasminecoffee.rb'
10
+ copy_file 'spec.js.coffee', 'spec/javascripts/spec.js.coffee'
11
+ copy_file 'example_spec.js.coffee', 'spec/javascripts/example_spec.js.coffee'
12
+ copy_file 'spec.css', 'spec/javascripts/spec.css'
13
+ copy_file 'example_fixture.html.haml', 'spec/javascripts/fixtures/example_fixture.html.haml'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,2 @@
1
+ %h2 Test Fixture
2
+ %p Using fixtures
@@ -0,0 +1,14 @@
1
+ # use require to load any .js file available to the asset pipeline
2
+ #= require foo
3
+ #= require bar
4
+
5
+ describe "Foo", ->
6
+ loadFixtures 'example_fixture' # located at 'spec/javascripts/fixtures/example_fixture.html.haml'
7
+ it "it is not bar", ->
8
+ v = new Foo()
9
+ expect(v.bar()).toEqual(false)
10
+
11
+ describe "Bar", ->
12
+ it "it is not foo", ->
13
+ v = new Bar()
14
+ expect(v.foo()).toEqual(false)
@@ -0,0 +1,19 @@
1
+ # Use this file to set configuration options for Jasminerice, all of these are initialized to their respective defaults,
2
+ # but you can change them here.
3
+ if defined?(JasmineCoffee) == 'constant'
4
+ JasmineCoffee.setup do |config|
5
+ # Tell Jasminerice to automatically mount itself in your application. If set to false, you must manually mount the
6
+ # engine in order to use Jasminerice.
7
+ #config.mount = true
8
+
9
+ # If automatically mounting Jasminerice, specify the location that it should be mounted at. Defaults to /jasmine, so
10
+ # you could access your tests at http://YOUR_SERVER_URL/jasmine
11
+ #config.mount_at = '/jasmine'
12
+
13
+ # Specify a path where your specs can be found. Defaults to 'spec'
14
+ #config.spec_path = 'spec'
15
+
16
+ # Specify a path where your fixutures can be found. Defaults to 'spec/javascripts/fixtures'
17
+ #config.fixture_path = 'spec/javascripts/fixtures'
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ /*
2
+ * Include the css files needed for javascript tests.
3
+ */
@@ -0,0 +1,7 @@
1
+ # This pulls in all your specs from the javascripts directory into Jasmine:
2
+ #
3
+ # spec/javascripts/*_spec.js.coffee
4
+ # spec/javascripts/*_spec.js
5
+ # spec/javascripts/*_spec.js.erb
6
+ #
7
+ #=require_tree ./
@@ -0,0 +1,38 @@
1
+ module Jasminerice
2
+ # Determine whether or not to mount the Jasminerice engine implicitly. True/False
3
+ mattr_accessor :mount
4
+ @@mount = true
5
+
6
+ # Specify location at which to mount the engine, default to '/jasmine'
7
+ mattr_accessor :mount_at
8
+ @@mount_at = '/jasmine'
9
+
10
+ # Specify the path for specs, defaults to 'spec'
11
+ mattr_accessor :spec_path
12
+ @@spec_path = 'spec'
13
+
14
+ #Specify the path for fixutures, defaults to 'spec/javascripts/fixtures'
15
+ mattr_accessor :fixture_path
16
+ @@fixture_path = 'spec/javascripts/fixtures'
17
+
18
+ # Default way to setup Jasminerice. Run rails generate jasminerice:install to create
19
+ # a fresh initializer with all configuration values.
20
+ def self.setup
21
+ yield self
22
+ end
23
+
24
+ class Engine < Rails::Engine
25
+ isolate_namespace Jasminerice
26
+
27
+ initializer :assets, :group => :all do |app|
28
+ app.config.assets.paths << Rails.root.join(Jasminerice.spec_path, "javascripts").to_s
29
+ app.config.assets.paths << Rails.root.join(Jasminerice.spec_path, "stylesheets").to_s
30
+ end
31
+
32
+ config.after_initialize do |app|
33
+ app.routes.prepend do
34
+ mount Jasminerice::Engine => Jasminerice.mount_at
35
+ end if Jasminerice.mount
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,120 @@
1
+ /**
2
+ Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
3
+
4
+ If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
5
+
6
+ The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
7
+
8
+ [jasmine-gem]: http://github.com/pivotal/jasmine-gem
9
+ */
10
+
11
+ (function() {
12
+
13
+ /**
14
+ * ## Require &amp; Instantiate
15
+ *
16
+ * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
17
+ */
18
+ window.jasmine = jasmineRequire.core(jasmineRequire);
19
+
20
+ /**
21
+ * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
22
+ */
23
+ jasmineRequire.html(jasmine);
24
+
25
+ /**
26
+ * Create the Jasmine environment. This is used to run all specs in a project.
27
+ */
28
+ var env = jasmine.getEnv();
29
+
30
+ /**
31
+ * ## The Global Interface
32
+ *
33
+ * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
34
+ */
35
+ var jasmineInterface = jasmineRequire.interface(jasmine, env);
36
+
37
+ /**
38
+ * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
39
+ */
40
+ if (typeof window == "undefined" && typeof exports == "object") {
41
+ extend(exports, jasmineInterface);
42
+ } else {
43
+ extend(window, jasmineInterface);
44
+ }
45
+
46
+ /**
47
+ * ## Runner Parameters
48
+ *
49
+ * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
50
+ */
51
+
52
+ var queryString = new jasmine.QueryString({
53
+ getWindowLocation: function() { return window.location; }
54
+ });
55
+
56
+ var catchingExceptions = queryString.getParam("catch");
57
+ env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
58
+
59
+ /**
60
+ * ## Reporters
61
+ * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
62
+ */
63
+ var htmlReporter = new jasmine.HtmlReporter({
64
+ env: env,
65
+ onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
66
+ getContainer: function() { return document.body; },
67
+ createElement: function() { return document.createElement.apply(document, arguments); },
68
+ createTextNode: function() { return document.createTextNode.apply(document, arguments); },
69
+ timer: new jasmine.Timer()
70
+ });
71
+
72
+ /**
73
+ * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
74
+ */
75
+ env.addReporter(jasmineInterface.jsApiReporter);
76
+ env.addReporter(htmlReporter);
77
+
78
+ /**
79
+ * Filter which specs will be run by matching the start of the full name against the `spec` query param.
80
+ */
81
+ var specFilter = new jasmine.HtmlSpecFilter({
82
+ filterString: function() { return queryString.getParam("spec"); }
83
+ });
84
+
85
+ env.specFilter = function(spec) {
86
+ return specFilter.matches(spec.getFullName());
87
+ };
88
+
89
+ /**
90
+ * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
91
+ */
92
+ window.setTimeout = window.setTimeout;
93
+ window.setInterval = window.setInterval;
94
+ window.clearTimeout = window.clearTimeout;
95
+ window.clearInterval = window.clearInterval;
96
+
97
+ /**
98
+ * ## Execution
99
+ *
100
+ * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
101
+ */
102
+ var currentWindowOnload = window.onload;
103
+
104
+ window.onload = function() {
105
+ if (currentWindowOnload) {
106
+ currentWindowOnload();
107
+ }
108
+ htmlReporter.initialize();
109
+ env.execute();
110
+ };
111
+
112
+ /**
113
+ * Helper function for readability above.
114
+ */
115
+ function extend(destination, source) {
116
+ for (var property in source) destination[property] = source[property];
117
+ return destination;
118
+ }
119
+
120
+ }());
@@ -0,0 +1,190 @@
1
+ /*
2
+ Copyright (c) 2008-2014 Pivotal Labs
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ function getJasmineRequireObj() {
24
+ if (typeof module !== 'undefined' && module.exports) {
25
+ return exports;
26
+ } else {
27
+ window.jasmineRequire = window.jasmineRequire || {};
28
+ return window.jasmineRequire;
29
+ }
30
+ }
31
+
32
+ getJasmineRequireObj().console = function(jRequire, j$) {
33
+ j$.ConsoleReporter = jRequire.ConsoleReporter();
34
+ };
35
+
36
+ getJasmineRequireObj().ConsoleReporter = function() {
37
+
38
+ var noopTimer = {
39
+ start: function(){},
40
+ elapsed: function(){ return 0; }
41
+ };
42
+
43
+ function ConsoleReporter(options) {
44
+ var print = options.print,
45
+ showColors = options.showColors || false,
46
+ onComplete = options.onComplete || function() {},
47
+ timer = options.timer || noopTimer,
48
+ specCount,
49
+ failureCount,
50
+ failedSpecs = [],
51
+ pendingCount,
52
+ ansi = {
53
+ green: '\x1B[32m',
54
+ red: '\x1B[31m',
55
+ yellow: '\x1B[33m',
56
+ none: '\x1B[0m'
57
+ },
58
+ failedSuites = [];
59
+
60
+ print('ConsoleReporter is deprecated and will be removed in a future version.');
61
+
62
+ this.jasmineStarted = function() {
63
+ specCount = 0;
64
+ failureCount = 0;
65
+ pendingCount = 0;
66
+ print('Started');
67
+ printNewline();
68
+ timer.start();
69
+ };
70
+
71
+ this.jasmineDone = function() {
72
+ printNewline();
73
+ for (var i = 0; i < failedSpecs.length; i++) {
74
+ specFailureDetails(failedSpecs[i]);
75
+ }
76
+
77
+ if(specCount > 0) {
78
+ printNewline();
79
+
80
+ var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
81
+ failureCount + ' ' + plural('failure', failureCount);
82
+
83
+ if (pendingCount) {
84
+ specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
85
+ }
86
+
87
+ print(specCounts);
88
+ } else {
89
+ print('No specs found');
90
+ }
91
+
92
+ printNewline();
93
+ var seconds = timer.elapsed() / 1000;
94
+ print('Finished in ' + seconds + ' ' + plural('second', seconds));
95
+ printNewline();
96
+
97
+ for(i = 0; i < failedSuites.length; i++) {
98
+ suiteFailureDetails(failedSuites[i]);
99
+ }
100
+
101
+ onComplete(failureCount === 0);
102
+ };
103
+
104
+ this.specDone = function(result) {
105
+ specCount++;
106
+
107
+ if (result.status == 'pending') {
108
+ pendingCount++;
109
+ print(colored('yellow', '*'));
110
+ return;
111
+ }
112
+
113
+ if (result.status == 'passed') {
114
+ print(colored('green', '.'));
115
+ return;
116
+ }
117
+
118
+ if (result.status == 'failed') {
119
+ failureCount++;
120
+ failedSpecs.push(result);
121
+ print(colored('red', 'F'));
122
+ }
123
+ };
124
+
125
+ this.suiteDone = function(result) {
126
+ if (result.failedExpectations && result.failedExpectations.length > 0) {
127
+ failureCount++;
128
+ failedSuites.push(result);
129
+ }
130
+ };
131
+
132
+ return this;
133
+
134
+ function printNewline() {
135
+ print('\n');
136
+ }
137
+
138
+ function colored(color, str) {
139
+ return showColors ? (ansi[color] + str + ansi.none) : str;
140
+ }
141
+
142
+ function plural(str, count) {
143
+ return count == 1 ? str : str + 's';
144
+ }
145
+
146
+ function repeat(thing, times) {
147
+ var arr = [];
148
+ for (var i = 0; i < times; i++) {
149
+ arr.push(thing);
150
+ }
151
+ return arr;
152
+ }
153
+
154
+ function indent(str, spaces) {
155
+ var lines = (str || '').split('\n');
156
+ var newArr = [];
157
+ for (var i = 0; i < lines.length; i++) {
158
+ newArr.push(repeat(' ', spaces).join('') + lines[i]);
159
+ }
160
+ return newArr.join('\n');
161
+ }
162
+
163
+ function specFailureDetails(result) {
164
+ printNewline();
165
+ print(result.fullName);
166
+
167
+ for (var i = 0; i < result.failedExpectations.length; i++) {
168
+ var failedExpectation = result.failedExpectations[i];
169
+ printNewline();
170
+ print(indent(failedExpectation.message, 2));
171
+ print(indent(failedExpectation.stack, 2));
172
+ }
173
+
174
+ printNewline();
175
+ }
176
+
177
+ function suiteFailureDetails(result) {
178
+ for (var i = 0; i < result.failedExpectations.length; i++) {
179
+ printNewline();
180
+ print(colored('red', 'An error was thrown in an afterAll'));
181
+ printNewline();
182
+ print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
183
+
184
+ }
185
+ printNewline();
186
+ }
187
+ }
188
+
189
+ return ConsoleReporter;
190
+ };