angularjs-rails-gem 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Configuration for jstd scenario adapter
3
+ */
4
+ var jstdScenarioAdapter = {
5
+ relativeUrlPrefix: '/build/docs/'
6
+ };
@@ -0,0 +1,185 @@
1
+ /**
2
+ * @license AngularJS v1.0.3
3
+ * (c) 2010-2012 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+ (function(window) {
7
+ 'use strict';
8
+
9
+ /**
10
+ * JSTestDriver adapter for angular scenario tests
11
+ *
12
+ * Example of jsTestDriver.conf for running scenario tests with JSTD:
13
+ <pre>
14
+ server: http://localhost:9877
15
+
16
+ load:
17
+ - lib/angular-scenario.js
18
+ - lib/jstd-scenario-adapter-config.js
19
+ - lib/jstd-scenario-adapter.js
20
+ # your test files go here #
21
+
22
+ proxy:
23
+ - {matcher: "/your-prefix/*", server: "http://localhost:8000/"}
24
+ </pre>
25
+ *
26
+ * For more information on how to configure jstd proxy, see {@link http://code.google.com/p/js-test-driver/wiki/Proxy}
27
+ * Note the order of files - it's important !
28
+ *
29
+ * Example of jstd-scenario-adapter-config.js
30
+ <pre>
31
+ var jstdScenarioAdapter = {
32
+ relativeUrlPrefix: '/your-prefix/'
33
+ };
34
+ </pre>
35
+ *
36
+ * Whenever you use <code>browser().navigateTo('relativeUrl')</code> in your scenario test, the relativeUrlPrefix will be prepended.
37
+ * You have to configure this to work together with JSTD proxy.
38
+ *
39
+ * Let's assume you are using the above configuration (jsTestDriver.conf and jstd-scenario-adapter-config.js):
40
+ * Now, when you call <code>browser().navigateTo('index.html')</code> in your scenario test, the browser will open /your-prefix/index.html.
41
+ * That matches the proxy, so JSTD will proxy this request to http://localhost:8000/index.html.
42
+ */
43
+
44
+ /**
45
+ * Custom type of test case
46
+ *
47
+ * @const
48
+ * @see jstestdriver.TestCaseInfo
49
+ */
50
+ var SCENARIO_TYPE = 'scenario';
51
+
52
+ /**
53
+ * Plugin for JSTestDriver
54
+ * Connection point between scenario's jstd output and jstestdriver.
55
+ *
56
+ * @see jstestdriver.PluginRegistrar
57
+ */
58
+ function JstdPlugin() {
59
+ var nop = function() {};
60
+
61
+ this.reportResult = nop;
62
+ this.reportEnd = nop;
63
+ this.runScenario = nop;
64
+
65
+ this.name = 'Angular Scenario Adapter';
66
+
67
+ /**
68
+ * Called for each JSTD TestCase
69
+ *
70
+ * Handles only SCENARIO_TYPE test cases. There should be only one fake TestCase.
71
+ * Runs all scenario tests (under one fake TestCase) and report all results to JSTD.
72
+ *
73
+ * @param {jstestdriver.TestRunConfiguration} configuration
74
+ * @param {Function} onTestDone
75
+ * @param {Function} onAllTestsComplete
76
+ * @returns {boolean} True if this type of test is handled by this plugin, false otherwise
77
+ */
78
+ this.runTestConfiguration = function(configuration, onTestDone, onAllTestsComplete) {
79
+ if (configuration.getTestCaseInfo().getType() != SCENARIO_TYPE) return false;
80
+
81
+ this.reportResult = onTestDone;
82
+ this.reportEnd = onAllTestsComplete;
83
+ this.runScenario();
84
+
85
+ return true;
86
+ };
87
+
88
+ this.getTestRunsConfigurationFor = function(testCaseInfos, expressions, testRunsConfiguration) {
89
+ testRunsConfiguration.push(
90
+ new jstestdriver.TestRunConfiguration(
91
+ new jstestdriver.TestCaseInfo(
92
+ 'Angular Scenario Tests', function() {}, SCENARIO_TYPE), []));
93
+
94
+ return true;
95
+ };
96
+ }
97
+
98
+ /**
99
+ * Singleton instance of the plugin
100
+ * Accessed using closure by:
101
+ * - jstd output (reports to this plugin)
102
+ * - initScenarioAdapter (register the plugin to jstd)
103
+ */
104
+ var plugin = new JstdPlugin();
105
+
106
+ /**
107
+ * Initialise scenario jstd-adapter
108
+ * (only if jstestdriver is defined)
109
+ *
110
+ * @param {Object} jstestdriver Undefined when run from browser (without jstd)
111
+ * @param {Function} initScenarioAndRun Function that inits scenario and runs all the tests
112
+ * @param {Object=} config Configuration object, supported properties:
113
+ * - relativeUrlPrefix: prefix for all relative links when navigateTo()
114
+ */
115
+ function initScenarioAdapter(jstestdriver, initScenarioAndRun, config) {
116
+ if (jstestdriver) {
117
+ // create and register ScenarioPlugin
118
+ jstestdriver.pluginRegistrar.register(plugin);
119
+ plugin.runScenario = initScenarioAndRun;
120
+
121
+ /**
122
+ * HACK (angular.scenario.Application.navigateTo)
123
+ *
124
+ * We need to navigate to relative urls when running from browser (without JSTD),
125
+ * because we want to allow running scenario tests without creating its own virtual host.
126
+ * For example: http://angular.local/build/docs/docs-scenario.html
127
+ *
128
+ * On the other hand, when running with JSTD, we need to navigate to absolute urls,
129
+ * because of JSTD proxy. (proxy, because of same domain policy)
130
+ *
131
+ * So this hack is applied only if running with JSTD and change all relative urls to absolute.
132
+ */
133
+ var appProto = angular.scenario.Application.prototype,
134
+ navigateTo = appProto.navigateTo,
135
+ relativeUrlPrefix = config && config.relativeUrlPrefix || '/';
136
+
137
+ appProto.navigateTo = function(url, loadFn, errorFn) {
138
+ if (url.charAt(0) != '/' && url.charAt(0) != '#' &&
139
+ url != 'about:blank' && !url.match(/^https?/)) {
140
+ url = relativeUrlPrefix + url;
141
+ }
142
+
143
+ return navigateTo.call(this, url, loadFn, errorFn);
144
+ };
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Builds proper TestResult object from given model spec
150
+ *
151
+ * TODO(vojta) report error details
152
+ *
153
+ * @param {angular.scenario.ObjectModel.Spec} spec
154
+ * @returns {jstestdriver.TestResult}
155
+ */
156
+ function createTestResultFromSpec(spec) {
157
+ var map = {
158
+ success: 'PASSED',
159
+ error: 'ERROR',
160
+ failure: 'FAILED'
161
+ };
162
+
163
+ return new jstestdriver.TestResult(
164
+ spec.fullDefinitionName,
165
+ spec.name,
166
+ jstestdriver.TestResult.RESULT[map[spec.status]],
167
+ spec.error || '',
168
+ spec.line || '',
169
+ spec.duration);
170
+ }
171
+
172
+ /**
173
+ * Generates JSTD output (jstestdriver.TestResult)
174
+ */
175
+ angular.scenario.output('jstd', function(context, runner, model) {
176
+ model.on('SpecEnd', function(spec) {
177
+ plugin.reportResult(createTestResultFromSpec(spec));
178
+ });
179
+
180
+ model.on('RunnerEnd', function() {
181
+ plugin.reportEnd();
182
+ });
183
+ });
184
+ initScenarioAdapter(window.jstestdriver, angular.scenario.setUpAndRun, window.jstdScenarioAdapter);
185
+ })(window);
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angularjs-rails-gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hirav Gandhi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Injects Angular.js into your asset pipeline as well as other Angular
15
+ modules.
16
+ email: hgandhi@alumni.stanford.edu
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/angularjs-rails/version.rb
22
+ - lib/angularjs-rails.rb
23
+ - vendor/assets/javascripts/angular-bootstrap-prettify.js
24
+ - vendor/assets/javascripts/angular-bootstrap.js
25
+ - vendor/assets/javascripts/angular-cookies.js
26
+ - vendor/assets/javascripts/angular-loader.js
27
+ - vendor/assets/javascripts/angular-mocks.js
28
+ - vendor/assets/javascripts/angular-resource.js
29
+ - vendor/assets/javascripts/angular-sanitize.js
30
+ - vendor/assets/javascripts/angular-scenario.js
31
+ - vendor/assets/javascripts/angular.js
32
+ - vendor/assets/javascripts/jstd-scenario-adapter-config.js
33
+ - vendor/assets/javascripts/jstd-scenario-adapter.js
34
+ - MIT-LICENSE
35
+ - README.md
36
+ homepage: https://github.com/confuseddesi/angularjs-rails/
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 1.8.24
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: Angular.js on Rails
60
+ test_files: []