Permalink
Browse files

New project with jasmine

  • Loading branch information...
0 parents commit 1034848ba7acc350bf41ba68edf737f26568ed39 @bkeepers bkeepers committed Apr 15, 2011
@@ -0,0 +1,4 @@
+source :rubygems
+gem 'rack', '~>1.1.0'
+gem 'jasmine'
+gem 'livereload'
@@ -0,0 +1,49 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.5)
+ childprocess (0.1.8)
+ ffi (~> 1.0.6)
+ diff-lcs (1.1.2)
+ em-dir-watcher (0.9.4)
+ em-websocket (0.2.1)
+ addressable (>= 2.1.1)
+ eventmachine (>= 0.12.9)
+ eventmachine (0.12.10)
+ ffi (1.0.7)
+ rake (>= 0.8.7)
+ jasmine (1.0.2.0)
+ json_pure (>= 1.4.3)
+ rack (>= 1.1)
+ rspec (>= 1.3.1)
+ selenium-webdriver (>= 0.1.3)
+ json_pure (1.5.1)
+ livereload (1.6)
+ em-dir-watcher (>= 0.1)
+ em-websocket (>= 0.1.2)
+ ruby-json (>= 1.1.2)
+ rack (1.1.2)
+ rake (0.8.7)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ ruby-json (1.1.2)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.4)
+ childprocess (>= 0.1.7)
+ ffi (>= 1.0.7)
+ json_pure
+ rubyzip
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ jasmine
+ livereload
+ rack (~> 1.1.0)
@@ -0,0 +1,4 @@
+require 'bundler/setup'
+load 'jasmine/tasks/jasmine.rake'
+
+task :default => 'jasmine:ci'
No changes.
@@ -0,0 +1,73 @@
+# src_files
+#
+# Return an array of filepaths relative to src_dir to include before jasmine specs.
+# Default: []
+#
+# EXAMPLE:
+#
+# src_files:
+# - lib/source1.js
+# - lib/source2.js
+# - dist/**/*.js
+#
+src_files:
+ - src/**/*.js
+
+# stylesheets
+#
+# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
+# Default: []
+#
+# EXAMPLE:
+#
+# stylesheets:
+# - css/style.css
+# - stylesheets/*.css
+#
+stylesheets:
+
+# helpers
+#
+# Return an array of filepaths relative to spec_dir to include before jasmine specs.
+# Default: ["helpers/**/*.js"]
+#
+# EXAMPLE:
+#
+# helpers:
+# - helpers/**/*.js
+#
+helpers:
+
+# spec_files
+#
+# Return an array of filepaths relative to spec_dir to include.
+# Default: ["**/*[sS]pec.js"]
+#
+# EXAMPLE:
+#
+# spec_files:
+# - **/*[sS]pec.js
+#
+spec_files:
+
+# src_dir
+#
+# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
+# Default: project root
+#
+# EXAMPLE:
+#
+# src_dir: public
+#
+src_dir:
+
+# spec_dir
+#
+# Spec directory path. Your spec_files must be returned relative to this path.
+# Default: spec/javascripts
+#
+# EXAMPLE:
+#
+# spec_dir: spec/javascripts
+#
+spec_dir:
@@ -0,0 +1,23 @@
+module Jasmine
+ class Config
+
+ # Add your overrides or custom config code here
+
+ end
+end
+
+
+# Note - this is necessary for rspec2, which has removed the backtrace
+module Jasmine
+ class SpecBuilder
+ def declare_spec(parent, spec)
+ me = self
+ example_name = spec["name"]
+ @spec_ids << spec["id"]
+ backtrace = @example_locations[parent.description + " " + example_name]
+ parent.it example_name, {} do
+ me.report_spec(spec["id"])
+ end
+ end
+ end
+end
@@ -0,0 +1,32 @@
+$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
+
+require 'rubygems'
+require 'jasmine'
+jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
+require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
+if Jasmine::rspec2?
+ require 'rspec'
+else
+ require 'spec'
+end
+
+jasmine_config = Jasmine::Config.new
+spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
+
+should_stop = false
+
+if Jasmine::rspec2?
+ RSpec.configuration.after(:suite) do
+ spec_builder.stop if should_stop
+ end
+else
+ Spec::Runner.configure do |config|
+ config.after(:suite) do
+ spec_builder.stop if should_stop
+ end
+ end
+end
+
+spec_builder.start
+should_stop = true
+spec_builder.declare_suites
@@ -0,0 +1,43 @@
+describe('JSHint', function () {
+ var options = {curly: true, indent: 2},
+ files = /^\/src|.*spec\.js$/;
+
+ function get(path) {
+ path = path + "?" + new Date().getTime();
+
+ var xhr;
+ try {
+ xhr = new jasmine.XmlHttpRequest();
+ xhr.open("GET", path, false);
+ xhr.send(null);
+ } catch (e) {
+ throw new Error("couldn't fetch " + path + ": " + e);
+ }
+ if (xhr.status < 200 || xhr.status > 299) {
+ throw new Error("Could not load '" + path + "'.");
+ }
+
+ return xhr.responseText;
+ }
+
+ _.each(document.getElementsByTagName('script'), function (element) {
+ var script = element.getAttribute('src');
+ if (!files.test(script)) {
+ return;
+ }
+
+ it(script, function () {
+ var self = this;
+ var source = get(script);
+ var result = JSHINT(source, options);
+ _.each(JSHINT.errors, function (error) {
+ self.addMatcherResult(new jasmine.ExpectationResult({
+ passed: false,
+ message: "line " + error.line + ' - ' + error.reason + ' - ' + error.evidence
+ }));
+ });
+ expect(true).toBe(true); // force spec to show up if there are no errors
+ });
+
+ });
+});

0 comments on commit 1034848

Please sign in to comment.