Skip to content

Commit

Permalink
Merged in Nate's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Davis W. Frank committed Feb 24, 2011
1 parent 3e6f62a commit f4050ee
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
jasmine (1.0.2.0beta4)
json_pure (>= 1.4.3)
selenium-client (>= 1.2.18)
selenium-rc (>= 2.2.1)
selenium-rc (>= 2.3.1)

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -79,7 +79,7 @@ GEM
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
selenium-client (1.2.18)
selenium-rc (2.2.4)
selenium-rc (2.3.1)
selenium-client (>= 1.2.18)
thor (0.14.6)
treetop (1.4.9)
Expand Down
4 changes: 2 additions & 2 deletions jasmine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]

s.add_dependency 'json_pure', '>= 1.4.3'
s.add_dependency 'selenium-rc', '>= 2.2.1'
s.add_dependency 'selenium-rc', '>= 2.3.1'
s.add_dependency 'selenium-client', '>= 1.2.18'

if ENV['RAILS_ENV'] == 'rails2'
if ENV['RAILS_VERSION'] == 'rails2'
# for development & test of Rails 2 Generators
s.add_development_dependency 'rspec', '1.3.1'
s.add_development_dependency 'rails', '2.3.10'
Expand Down
32 changes: 32 additions & 0 deletions lib/generators/jasmine/jasmine_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class JasmineGenerator < Rails::Generator::Base
def manifest
m = ::Rails::Generator::Manifest.new

m.directory "public/javascripts"
m.file "jasmine-example/src/Player.js", "public/javascripts/Player.js"
m.file "jasmine-example/src/Song.js", "public/javascripts/Song.js"

m.directory "spec/javascripts"
m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"

m.directory "spec/javascripts/helpers"
m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"

m.directory "spec/javascripts/support"
m.file "spec/javascripts/support/jasmine_runner.rb", "spec/javascripts/support/jasmine_runner.rb"
m.file "spec/javascripts/support/jasmine_config.rb", "spec/javascripts/support/jasmine_config.rb"
m.file "spec/javascripts/support/jasmine-rails.yml", "spec/javascripts/support/jasmine.yml"
m.readme "INSTALL"

unless ::Rails::VERSION::STRING[0,1] == "3"
m.directory "lib/tasks"
m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake"
end
m
end

def file_name
"create_blog"
end

end
9 changes: 9 additions & 0 deletions lib/generators/jasmine/templates/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Jasmine has been installed with example specs.

To run the server:

rake jasmine

To run the automated CI task with Selenium:

rake jasmine:ci
2 changes: 2 additions & 0 deletions lib/generators/jasmine/templates/lib/tasks/jasmine.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# 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/prototype.js
- public/javascripts/effects.js
- public/javascripts/controls.js
- public/javascripts/dragdrop.js
- public/javascripts/application.js
- 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:
- stylesheets/**/*.css

# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
- helpers/**/*.js

# 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:
- **/*[sS]pec.js

# 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: spec/javascripts
Original file line number Diff line number Diff line change
@@ -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:
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/jasmine/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def start_selenium_server
@selenium_server_port = external_selenium_server_port
if @selenium_server_port.nil?
@selenium_server_port = Jasmine::find_unused_port
require 'selenium_rc'
require 'selenium-rc'
SeleniumRC::Server.send(:include, SeleniumServerForkHackForRSpec)
SeleniumRC::Server.boot("localhost", @selenium_server_port, :args => [windows? ? ">NUL" : "> /dev/null"])
else
Expand Down

0 comments on commit f4050ee

Please sign in to comment.