diff --git a/.rvmrc b/.rvmrc index 369a829..84b7815 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1 @@ -rvm use 1.9.2@bb-sinatra-boiler --create +rvm use 1.9.2@jscalc --create diff --git a/Gemfile.lock b/Gemfile.lock index 2e01971..c1fd90d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,11 +2,14 @@ GEM remote: http://rubygems.org/ specs: backports (2.3.0) + childprocess (0.3.0) + ffi (~> 1.0.6) chunky_png (1.2.5) compass (0.11.7) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) + diff-lcs (1.1.3) eventmachine (0.12.10) ffi (1.0.11) fssm (0.2.8.1) @@ -21,14 +24,35 @@ GEM guard (>= 0.4.2) spoon (~> 0.0.1) haml (3.1.4) + jasmine (1.1.2) + jasmine-core (>= 1.1.0) + rack (>= 1.1) + rspec (>= 1.3.1) + selenium-webdriver (>= 0.1.3) + jasmine-core (1.1.0) json (1.6.5) + multi_json (1.0.4) rack (1.4.0) rack-protection (1.2.0) rack rack-test (0.6.1) rack (>= 1.0) rb-fsevent (0.4.3.1) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + rubyzip (0.9.5) sass (3.1.12) + selenium-webdriver (2.17.0) + childprocess (>= 0.2.5) + ffi (~> 1.0.9) + multi_json (~> 1.0.4) + rubyzip sinatra (1.3.2) rack (~> 1.3, >= 1.3.6) rack-protection (~> 1.2) @@ -55,6 +79,7 @@ DEPENDENCIES guard-compass guard-process haml + jasmine json rb-fsevent sass diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..d673004 --- /dev/null +++ b/Rakefile @@ -0,0 +1,9 @@ + +begin + require 'jasmine' + load 'jasmine/tasks/jasmine.rake' +rescue LoadError + task :jasmine do + abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine" + end +end diff --git a/spec/javascripts/helpers/SpecHelper.js b/spec/javascripts/helpers/SpecHelper.js new file mode 100644 index 0000000..e9b8284 --- /dev/null +++ b/spec/javascripts/helpers/SpecHelper.js @@ -0,0 +1,9 @@ +beforeEach(function() { + this.addMatchers({ + toBePlaying: function(expectedSong) { + var player = this.actual; + return player.currentlyPlayingSong === expectedSong && + player.isPlaying; + } + }); +}); diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml new file mode 100644 index 0000000..7cce692 --- /dev/null +++ b/spec/javascripts/support/jasmine.yml @@ -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: + - public/javascripts/**/*.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: diff --git a/spec/javascripts/support/jasmine_config.rb b/spec/javascripts/support/jasmine_config.rb new file mode 100644 index 0000000..47286f2 --- /dev/null +++ b/spec/javascripts/support/jasmine_config.rb @@ -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 diff --git a/spec/javascripts/support/jasmine_runner.rb b/spec/javascripts/support/jasmine_runner.rb new file mode 100644 index 0000000..f3944f3 --- /dev/null +++ b/spec/javascripts/support/jasmine_runner.rb @@ -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::Dependencies.rspec2? + require 'rspec' +else + require 'spec' +end + +jasmine_config = Jasmine::Config.new +spec_builder = Jasmine::SpecBuilder.new(jasmine_config) + +should_stop = false + +if Jasmine::Dependencies.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