drogus-blue-ridge 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/LICENSE +20 -0
  2. data/LICENSE-Screw.Unit +22 -0
  3. data/LICENSE-Smoke +22 -0
  4. data/README.markdown +256 -0
  5. data/Rakefile +65 -0
  6. data/VERSION +1 -0
  7. data/blue_ridge_generators/blue_ridge/USAGE +5 -0
  8. data/blue_ridge_generators/blue_ridge/blue_ridge_generator.rb +19 -0
  9. data/blue_ridge_generators/blue_ridge/templates/application.html +16 -0
  10. data/blue_ridge_generators/blue_ridge/templates/application_spec.js +15 -0
  11. data/blue_ridge_generators/blue_ridge/templates/javascript_spec_helper.rb +44 -0
  12. data/blue_ridge_generators/blue_ridge/templates/screw.css +90 -0
  13. data/blue_ridge_generators/blue_ridge/templates/spec_helper.js +1 -0
  14. data/blue_ridge_generators/javascript_spec/USAGE +5 -0
  15. data/blue_ridge_generators/javascript_spec/javascript_spec_generator.rb +52 -0
  16. data/blue_ridge_generators/javascript_spec/templates/fixture.html.erb +13 -0
  17. data/blue_ridge_generators/javascript_spec/templates/fixture_render_spec.rb.erb +10 -0
  18. data/blue_ridge_generators/javascript_spec/templates/javascript_spec.js.erb +10 -0
  19. data/lib/blue-ridge.js +73 -0
  20. data/lib/consoleReportForRake.js +32 -0
  21. data/lib/env.rhino.js +8841 -0
  22. data/lib/jquery-1.2.6.js +3549 -0
  23. data/lib/jquery-1.3.2.js +4376 -0
  24. data/lib/jquery.fn.js +29 -0
  25. data/lib/jquery.print.js +109 -0
  26. data/lib/js.jar +0 -0
  27. data/lib/screw.behaviors.js +92 -0
  28. data/lib/screw.builder.js +82 -0
  29. data/lib/screw.events.js +45 -0
  30. data/lib/screw.matchers.js +187 -0
  31. data/lib/screw.mocking.js +26 -0
  32. data/lib/shell.js +27 -0
  33. data/lib/smoke.core.js +49 -0
  34. data/lib/smoke.mock.js +171 -0
  35. data/lib/smoke.stub.js +29 -0
  36. data/lib/test_runner.js +58 -0
  37. data/spec/fixtures/rails_project/app/controllers/accounts_controller.rb +85 -0
  38. data/spec/fixtures/rails_project/app/controllers/application_controller.rb +10 -0
  39. data/spec/fixtures/rails_project/app/controllers/home_controller.rb +5 -0
  40. data/spec/fixtures/rails_project/app/helpers/accounts_helper.rb +2 -0
  41. data/spec/fixtures/rails_project/app/helpers/application_helper.rb +13 -0
  42. data/spec/fixtures/rails_project/app/helpers/home_helper.rb +2 -0
  43. data/spec/fixtures/rails_project/app/models/account.rb +3 -0
  44. data/spec/fixtures/rails_project/config/boot.rb +110 -0
  45. data/spec/fixtures/rails_project/config/environment.rb +41 -0
  46. data/spec/fixtures/rails_project/config/environments/cucumber.rb +25 -0
  47. data/spec/fixtures/rails_project/config/environments/development.rb +17 -0
  48. data/spec/fixtures/rails_project/config/environments/production.rb +28 -0
  49. data/spec/fixtures/rails_project/config/environments/test.rb +35 -0
  50. data/spec/fixtures/rails_project/config/initializers/backtrace_silencers.rb +7 -0
  51. data/spec/fixtures/rails_project/config/initializers/inflections.rb +10 -0
  52. data/spec/fixtures/rails_project/config/initializers/mime_types.rb +5 -0
  53. data/spec/fixtures/rails_project/config/initializers/new_rails_defaults.rb +19 -0
  54. data/spec/fixtures/rails_project/config/initializers/session_store.rb +2 -0
  55. data/spec/fixtures/rails_project/config/routes.rb +47 -0
  56. data/spec/fixtures/rails_project/db/migrate/20090719005327_create_sessions.rb +16 -0
  57. data/spec/fixtures/rails_project/db/migrate/20090719031606_create_accounts.rb +13 -0
  58. data/spec/fixtures/rails_project/db/schema.rb +30 -0
  59. data/spec/fixtures/rails_project/spec/spec_helper.rb +52 -0
  60. data/tasks/javascript_testing_tasks.rake +84 -0
  61. data/test/test_blue_ridge_generator.rb +48 -0
  62. data/test/test_generator_helper.rb +29 -0
  63. data/test/test_javascript_spec_generator.rb +57 -0
  64. metadata +148 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2009 Relevance, Inc.
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.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Nick Kallen
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ 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
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Andy Kent
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ 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
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,256 @@
1
+ Blue Ridge JavaScript Testing Rails Plugin
2
+ ==========================================
3
+
4
+ The Blue Ridge JavaScript Testing Rails Plugin adds support for command-line and in-browser JavaScript unit tests to your Rails app. It bundles several great tools together in a convention-over-configuration, Rails-like way. These tools include:
5
+
6
+ * `Rhino` - a Java-based JavaScript interpreter
7
+ * `Screw.Unit` - a behaviour-driven development syntax for JavaScript similar to RSpec
8
+ * `Smoke` - a JavaScript mocking & stubbing library similar to Mocha
9
+ * `env.js` - a DOM implementation written entirely in JavaScript
10
+
11
+ Installing and Running
12
+ ----------------------
13
+
14
+ To install:
15
+
16
+ ./script/plugin install git://github.com/relevance/blue-ridge.git
17
+ ./script/generate blue_ridge
18
+
19
+ To run all of the specs:
20
+
21
+ rake test:javascripts
22
+
23
+ (Hint: You can also use the `spec:javascripts` or `examples:javascripts` aliases.)
24
+
25
+ To run an individual spec file called "application_spec.js":
26
+
27
+ rake test:javascripts TEST=application
28
+
29
+ To generate and run a spec for a JavaScript file called "public/javascripts/graphics.js" run:
30
+
31
+ ./script/generate javascript_spec graphics
32
+ rake test:javascripts TEST=graphics
33
+
34
+ To run your spec inside a web browser, load the `HTML fixture` associated with the spec. (See below for more information on HTML fixtures and in-browser testing).
35
+
36
+ Fixtures rendered from Rails templates
37
+ ======================================
38
+
39
+ If you have a template at path app/views/xxx/yyy.html.erb, then you can have your
40
+ test fixture HTML file rendered automatically from that template.
41
+
42
+ Using the generator:
43
+ script/generate javascript_spec xxx_yyy xxx/yyy.html.erb
44
+ spec spec/javascripts/xxx_yyy_spec.rb
45
+
46
+ The latter command will do two things:
47
+ i) generate the spec/javascripts/fixtures/xxx_yyy.html based on the template
48
+ ii) run the spec/javascripts/xxx_yyy_spec.js tests in headless mode
49
+
50
+ To update the database + stub out template methods (like current_user),
51
+ modify the block in spec/javascripts/xxx_yyy_spec.rb.
52
+
53
+ If you are not using rspec, or don't pass the xxx/yyy.html.erb argument
54
+ to the javascript_spec generator, a blank fixture file will be generated
55
+ as described earlier.
56
+
57
+ Directory Layout: Specs and Fixtures
58
+ -------------------------------------
59
+
60
+ ### JavaScript Spec Directories
61
+
62
+ Blue Ridge creates a directory for your JavaScript specs in one of the following directories, depending on which tool you use to test your Ruby code:
63
+
64
+ * examples/javascripts: if you're using [Micronaut](http://github.com/spicycode/micronaut)
65
+ * spec/javascripts: if you're using [RSpec](http://rspec.info/)
66
+ * test/javascript: if you're using anything else
67
+
68
+ The layout of the JavaScript spec directories looks like this (assuming you created a "graphics" spec as described in the section above):
69
+
70
+ #### "javascripts" directory
71
+ * application_spec.js: file with Screw.Unit specs; intended for testing code in public/javascripts/application.js
72
+ * graphics_spec.js: another spec file; intended for testing code in public/javascripts/graphics.js
73
+ * spec_helper.js: a place a you to store your common configuration & convenience functions; auto-included by each spec
74
+
75
+ #### "javascripts/fixtures" directory
76
+ * application.html: base DOM for application_spec.js; also runs specs in-browser
77
+ * graphics.html: base DOM for graphics_spec.js; also runs specs in-browser
78
+ * screw.css: stylesheet for Screw.Unit output when running specs in-browser
79
+
80
+ ### Why We Need Fixtures
81
+ Blue Ridge relies on the convention that each spec file will have a similarly named HTML file in the `fixtures` directory. We create one fixture per spec file so that env.js has a base DOM to emulate when running specs from the command line and so that we have an HTML launch-pad to run our specs in-browser.
82
+
83
+ If you want to have specific HTML for a suite of specs, put it in the HTML fixture for that suite. If you want to run a specific suite of tests in Firefox or Internet Explorer, open the HTML fixture file with the same name and Screw.Unit automatically runs the specs associated with the fixture.
84
+
85
+ Example Using jQuery
86
+ ---------------------------------------
87
+
88
+ Blue Ridge is opinionated and assumes you're using jQuery by default. The plugin itself actually uses jQuery under the covers to run Screw.Unit.
89
+
90
+ require("spec_helper.js");
91
+ require("../../public/javascripts/application.js");
92
+
93
+ Screw.Unit(function() {
94
+ describe("Your application javascript", function() {
95
+ it("does something", function() {
96
+ expect("hello").to(equal, "hello");
97
+ });
98
+
99
+ it("accesses the DOM from fixtures/application.html", function() {
100
+ expect($('.select_me').length).to(equal, 2);
101
+ });
102
+ });
103
+ });
104
+
105
+ (By the way, we don’t actually encourage you to write specs and tests for standard libraries like JQuery and Prototype. It just makes for an easy demo.)
106
+
107
+ Example Using Prototype
108
+ -----------------------
109
+
110
+ It's very easy to add support for Prototype. Here's an example spec:
111
+
112
+ jQuery.noConflict();
113
+
114
+ require("spec_helper.js");
115
+ require("../../public/javascripts/prototype.js", {onload: function() {
116
+ require("../../public/javascripts/application.js");
117
+ }});
118
+
119
+ Screw.Unit(function() {
120
+ describe("Your application javascript", function() {
121
+ it("does something", function() {
122
+ expect("hello").to(equal, "hello");
123
+ });
124
+
125
+ it("accesses the DOM from fixtures/application.html", function() {
126
+ expect($$('.select_me').length).to(equal, 2);
127
+ });
128
+ });
129
+ });
130
+
131
+ Note that you must do the following:
132
+
133
+ * put jQuery into "no conflict" mode to give the `$` function back to Prototype
134
+ * require the `prototype.js` file
135
+ * chain any files that are dependent on `prototype.js` in the `onload` callback
136
+
137
+ More Examples
138
+ -------------
139
+
140
+ To see Blue Ridge in action inside a working Rails app, check out the [Blue Ridge sample application](http://github.com/relevance/blue-ridge-sample-app). Among other things, this sample app includes examples of:
141
+
142
+ * using nested `describe` functions
143
+ * setting up per-spec HTML "fixtures"
144
+ * stubbing functions
145
+ * mocking functions
146
+ * running the Blue Ridge specs as part of your default Rake task
147
+
148
+ JavaScript API
149
+ --------------
150
+
151
+ The Blue Ridge plugin provides a handful of functions that help you write specs that run correctly inside a web browser as well from the Rhino command-line test runner.
152
+
153
+ ### require(fileName, [{onload:function}])
154
+ When running from the command line, `require` becomes a Rhino call to `load`. In a web browser, `require` dynamically creates a JavaScript `script` tag and loads the given file for you. It takes an optional `onload` callback function that runs immediately after the given JavaScript file is loaded. This helps you chain dependencies. This is especially useful when running in-browser where each JavaScript file is loaded asynchronously in a separate thread.
155
+
156
+ require("../../public/javascripts/prerequisite.js", {onload: function() {
157
+ require("../../public/javascripts/dependent_file1.js");
158
+ require("../../public/javascripts/dependent_file2.js");
159
+ }});
160
+
161
+ ### debug(message)
162
+ When running from the command line, `debug` simply prints a message to stdout, but in a web browser it outputs into the DOM directly. This helps you avoid using the `print` function which prints to stdout in Rhino but actually opens a file print dialog when running in a browser!
163
+
164
+ ### console.debug(message)
165
+ If you use Firebug, you might add a `console.debug` function call in your tests to debug a problem. Calling this from the command-line would crash, however, because Firebug is missing. To make life a little easier, this `console.debug` function is just an alias to Rhino's `print` function and will write your message to stdout.
166
+
167
+ Extras
168
+ -------------
169
+
170
+ ### rake js:fixtures
171
+ If you're on Mac OS X, this command opens your JavaScript fixtures directory using Finder so you can quickly locate and open any spec that you want to run in the browser. If you're running on Linux, it opens the fixtures directory using Firefox.
172
+
173
+ ### rake js:shell
174
+ Runs an IRB-like JavaScript shell for debugging your JavaScript code. jQuery and env.js are pre-loaded for you to make debugging DOM code easy.
175
+
176
+ rake js:shell
177
+
178
+ =================================================
179
+ Rhino JavaScript Shell
180
+ To exit type 'exit', 'quit', or 'quit()'.
181
+ =================================================
182
+ - loaded env.js
183
+ - sample DOM loaded
184
+ - jQuery-1.2.6 loaded
185
+ =================================================
186
+ Rhino 1.7 release 2 PRERELEASE 2008 07 28
187
+ js> print("Hello World!")
188
+ Hello World!
189
+ js>
190
+
191
+ Note that if you have `rlwrap` installed and on the command line path (and you really, really should!), then command-line history and readline arrow-up and down will be properly supported automatically. (You can get `rlwrap` from your friendly neighborhood package manager.)
192
+
193
+ Mocking Example with Smoke
194
+ --------------------------
195
+ Smoke is a JavaScript mocking and stubbing toolkit that is somewhat similar to FlexMock or Mocha. It is automatically wired-in to undo its mocking after each Screw.Unit `it` block. Here's an example.
196
+
197
+ it("calculates the total cost of a contract by adding the prices of each component", function() {
198
+ var componentX = {}, componentY = {};
199
+ mock(SalesContract).should_receive("calculateComponentPrice").with_arguments(componentX).exactly(1, "times").and_return(42);
200
+ mock(SalesContract).should_receive("calculateComponentPrice").with_arguments(componentY).exactly(1, "times").and_return(24);
201
+ expect(SalesContract.calculateTotalCost([componentX, componentY])).to(equal, 66);
202
+ });
203
+
204
+ TextMate Integration
205
+ --------------------
206
+ Run your specs directory from TextMate using the [Blue Ridge TextMate Bundle](http://github.com/karnowski/blue-ridge-tmbundle). (It's a fork of the original [Screw.Unit TextMate Bundle](http://github.com/coreyti/screw-unit-tmbundle) but adapted for use with the Blue Ridge plugin.)
207
+
208
+ cd ~/Library/Application Support/TextMate/Bundles/
209
+ git clone git://github.com/karnowski/blue-ridge-tmbundle.git Blue\ Ridge.tmbundle
210
+
211
+ Then when editing a Screw.Unit spec file in TextMate you can:
212
+ * press command-R to run the spec directly from TextMate
213
+ * type snippets like "it", "des", "bef", "aft" and then press the tab key to expand into full it blocks, describe blocks, etc.
214
+
215
+ Tips & Tricks
216
+ -------------
217
+ * Avoid using `print` in your tests while debugging. It works fine from the command line but causes lots of headaches in browser. (Just imagine a print dialog opening ten or fifteen times and then Firefox crashing. This is a mistake I've made too many times! Trust me!)
218
+ * We don't recommend testing jQuery or Prototype, especially event wiring. (You don't test Rails, do you?) Instead write a separate function, test it, and wire it to events using jQuery or Prototype.
219
+
220
+ Bugs & Patches
221
+ --------------
222
+ First, if you see any bugs or possible improvements, please use the project's [GitHub issue tracker](http://github.com/relevance/blue-ridge/issues) to let us know about them.
223
+
224
+ But even better, fork our [GitHub repo](http://www.github.com/relevance/blue-ridge) and start hacking! If you have patches, send us pull requests. Also, [env.js](http://github.com/thatcher/env-js), [Smoke](http://github.com/andykent/smoke), and [Screw.Unit](http://github.com/nkallen/screw-unit) could use your love too!
225
+
226
+ Links
227
+ -------------
228
+ * [Blue Ridge JavaScript Testing Rails Plugin](http://github.com/relevance/blue-ridge)
229
+ * [Blue Ridge Sample App](http://github.com/relevance/blue-ridge-sample-app)
230
+ * [Justin Gehtland's "Fully Headless JSSpec" Blog Post](http://blog.thinkrelevance.com/2008/7/31/fully-headless-jsspec)
231
+ * [Screw.Unit](http://github.com/nkallen/screw-unit)
232
+ * [Screw.Unit Mailing List](http://groups.google.com/group/screw-unit)
233
+ * [Smoke](http://github.com/andykent/smoke)
234
+ * [env.js](http://github.com/thatcher/env-js)
235
+ * [env.js Mailing List](http://groups.google.com/group/envjs)
236
+ * [Mozilla Rhino](http://www.mozilla.org/rhino/)
237
+ * [W3C DOM Specifications](http://www.w3.org/DOM/DOMTR)
238
+
239
+ Contributors
240
+ ------------
241
+ * Justin Gehtland
242
+ * Geof Dagley
243
+ * Larry Karnowski
244
+ * Chris Thatcher (for numerous env.js bug fixes!)
245
+ * Raimonds Simanovskis
246
+ * Jason Rudolph
247
+ * Jonas Nicklas (original fixture rendering code http://gist.github.com/148947)
248
+ * Dr Nic Williams
249
+
250
+ Copyrights
251
+ ------------
252
+ * Copyright © 2008-2009 [Relevance, Inc.](http://www.thinkrelevance.com/), under the MIT license
253
+ * env.js - Copyright 2007-2009 John Resig, under the MIT License
254
+ * Screw.Unit - Copyright 2008 Nick Kallen, license attached
255
+ * Rhino - Copyright 2009 Mozilla Foundation, GPL 2.0
256
+ * Smoke - Copyright 2008 Andy Kent, license attached
@@ -0,0 +1,65 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ ENV['APP_ROOT'] = ENV["BLUE_RIDGE_PREFIX"] = File.dirname(__FILE__)
5
+
6
+ import File.dirname(__FILE__) + '/tasks/javascript_testing_tasks.rake'
7
+
8
+ task :default => "test:javascripts"
9
+
10
+ begin
11
+ require 'jeweler'
12
+ Jeweler::Tasks.new do |gem|
13
+ gem.name = "blue-ridge"
14
+ gem.summary = %Q{JavaScript BDD Gem (using Screw.Unit and env.js)}
15
+ gem.description = %Q{JavaScript BDD Gem (using Screw.Unit and env.js)}
16
+ gem.email = "drogus@gmail.com"
17
+ gem.homepage = "http://github.com/drogus/blue-ridge"
18
+ gem.authors = ["Piotr Sarnacki"]
19
+ gem.add_dependency "rubigen"
20
+ gem.add_development_dependency "rspec", ">= 1.2.9"
21
+ gem.add_development_dependency "yard", ">= 0"
22
+ gem.files = []
23
+ gem.files = FileList[
24
+ "lib/**/*",
25
+ "blue_ridge_generators/**/*",
26
+ "LICENCE",
27
+ "LICENCE-Screw.Unit",
28
+ "LICENCE-Smoke",
29
+ "README.markdown",
30
+ "Rakefile",
31
+ "tasks/**/*.rb",
32
+ "tasks/**/*.rake",
33
+ "VERSION"
34
+ ]
35
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
36
+ end
37
+ Jeweler::GemcutterTasks.new
38
+ rescue LoadError
39
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
40
+ end
41
+
42
+ require 'spec/rake/spectask'
43
+ Spec::Rake::SpecTask.new(:spec) do |spec|
44
+ spec.libs << 'lib' << 'spec'
45
+ spec.spec_files = FileList['spec/**/*_spec.rb']
46
+ end
47
+
48
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
49
+ spec.libs << 'lib' << 'spec'
50
+ spec.pattern = 'spec/**/*_spec.rb'
51
+ spec.rcov = true
52
+ end
53
+
54
+ task :spec => :check_dependencies
55
+
56
+ task :default => :spec
57
+
58
+ begin
59
+ require 'yard'
60
+ YARD::Rake::YardocTask.new
61
+ rescue LoadError
62
+ task :yardoc do
63
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
64
+ end
65
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,19 @@
1
+ class BlueRidgeGenerator < RubiGen::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ m.directory base_dir
6
+ m.file 'application_spec.js', "#{base_dir}/application_spec.js"
7
+ m.file 'spec_helper.js', "#{base_dir}/spec_helper.js"
8
+ m.file 'javascript_spec_helper.rb', "#{base_dir}/javascript_spec_helper.rb"
9
+
10
+ m.directory "#{base_dir}/fixtures"
11
+ m.file 'application.html', "#{base_dir}/fixtures/application.html"
12
+ m.file 'screw.css', "#{base_dir}/fixtures/screw.css"
13
+ end
14
+ end
15
+
16
+ def base_dir
17
+ @base_dir ||= File.exist?("examples") ? "examples/javascripts" : File.exist?("spec") ? "spec/javascripts" : "test/javascript"
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <title>Application | JavaScript Testing Results</title>
6
+ <link rel="stylesheet" href="screw.css" type="text/css" charset="utf-8" />
7
+ <script type="text/javascript" src="../../../vendor/plugins/blue-ridge/lib/blue-ridge.js"></script>
8
+ </head>
9
+
10
+ <body>
11
+ <!-- Put any HTML fixture elements here. -->
12
+ <div class="select_me"/>
13
+ <span class="select_me"/>
14
+ <div class="dont_select_me"/>
15
+ </body>
16
+ </html>
@@ -0,0 +1,15 @@
1
+ require("spec_helper.js");
2
+ require("../../public/javascripts/application.js");
3
+
4
+ Screw.Unit(function(){
5
+ describe("Your application javascript", function(){
6
+ it("does something", function(){
7
+ expect("hello").to(equal, "hello");
8
+ });
9
+
10
+ it("accesses the DOM from fixtures/application.html", function(){
11
+ expect($('.select_me').length).to(equal, 2);
12
+ });
13
+ });
14
+ });
15
+