Skip to content

Commit

Permalink
Merge branch 'upstream' into m
Browse files Browse the repository at this point in the history
Conflicts:
	lib/jasmine/config.rb
	lib/jasmine/server.rb
  • Loading branch information
mpd committed Mar 27, 2013
2 parents fe0e29d + 7cbb951 commit e4c981f
Show file tree
Hide file tree
Showing 66 changed files with 1,730 additions and 987 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ matrix:
env: RAILS_VERSION=pojs-rspec2
allow_failures:
- rvm: rbx
- rvm: jruby
9 changes: 1 addition & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ gemspec

unless ENV["TRAVIS"]
group :debug do
# curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
# curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
# # Replace with your ruby path if necessary
# gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p125/
# rm linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'debugger'
end
end
2 changes: 1 addition & 1 deletion MIT.LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2008-2010 Pivotal Labs
Copyright (c) 2008-2012 Pivotal Labs

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
10 changes: 7 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ This gem contains:

You can get all of this by: `gem install jasmine` or by adding Jasmine to your `Gemfile`.

```ruby
group :development, :test do
gem 'jasmine'
end
```

## Init A Project

To initialize a project for Jasmine, it depends on your web framework
Expand Down Expand Up @@ -46,15 +52,13 @@ For Continuous Integration environments, add this task to the project build step

`rake jasmine:ci`

This uses Selenium to launch a browser and run the Jasmine suite. Then it uses RSpec to extract the results from the Jasmine reporter and write them to your build log.
This uses Selenium to launch a browser and run the Jasmine suite. Then it uses RSpec to extract the results from the Jasmine reporter and write them to your build log. The browser used by selenium can be changed by setting the JASMINE_BROWSER environment variable (this might require additional webdriver dependencies).

## Configuration

Customize `spec/javascripts/support/jasmine.yml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
You may use dir glob strings.

For more complex configuration (e.g., port number), edit `spec/javascripts/support/jasmine_config.rb` file directly.

## Note about the CI task and RSpec

This gem requires RSpec for the `jasmine:ci` rake task to work. But this gem does not explicitly *depend* on any version of the RSpec gem.
Expand Down
13 changes: 11 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,19 @@ task :default => :spec

namespace :jasmine do
require "jasmine-core"
require './spec/jasmine_self_test_config'
task :server do
port = ENV['JASMINE_PORT'] || 8888
JasmineSelfTestConfig.new.start_server(port)
Jasmine.configure do |config|
root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
config.src_dir = File.join(root, 'src')
config.spec_dir = Jasmine::Core.path
config.spec_files = lambda { (Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files).map {|f| File.join(config.spec_dir, f) } }
end

config = Jasmine.config

server = Jasmine::Server.new(8888, Jasmine::Application.app(config))
server.start

puts "your tests are here:"
puts " http://localhost:#{port}/"
Expand Down
1 change: 1 addition & 0 deletions generators/jasmine/jasmine_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def manifest

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

m.directory "lib/tasks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ stylesheets:
# - helpers/**/*.js
#
helpers:
- helpers/**/*.js
- 'helpers/**/*.js'

# spec_files
#
Expand All @@ -53,7 +53,7 @@ helpers:
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
# - '**/*[sS]pec.js'
#
spec_files:
- '**/*[sS]pec.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ stylesheets:
# - helpers/**/*.js
#
helpers:

- 'helpers/**/*.js'
# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
Expand All @@ -49,6 +49,7 @@ helpers:
# - **/*[sS]pec.js
#
spec_files:
- '**/*[sS]pec.js'

# src_dir
#
Expand All @@ -71,3 +72,17 @@ src_dir:
# spec_dir: spec/javascripts
#
spec_dir:

# spec_helper
#
# Ruby file that Jasmine server will require before starting.
# Returned relative to your root path
# Default spec/support/jasmine_helper.rb
#
# EXAMPLE:
#
# spec_helper: spec/support/jasmine_helper.rb
#
spec_helper: spec/support/jasmine_helper.rb


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Use this file to set/override Jasmine configuration options
#You can remove it if you don't need it.
#This file is loaded *after* jasmine.yml is interpreted.
#
#Example: using a different boot file.
#Jasmine.configure do |config|
# config.boot_dir = '/absolute/path/to/boot_dir'
# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
#end
#

7 changes: 5 additions & 2 deletions jasmine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Gem::Specification.new do |s|
s.summary = %q{JavaScript BDD framework}
s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
s.email = %q{[email protected]}
s.homepage = "http://pivotal.github.com/jasmine"
s.homepage = "http://pivotal.github.com/jasmine/"
s.license = "MIT"

s.files = `git ls-files`.split("\n") | Dir.glob('jasmine/**/*')
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down Expand Up @@ -66,7 +67,9 @@ Gem::Specification.new do |s|
s.add_development_dependency 'json_pure'
s.add_development_dependency 'nokogiri'

s.add_dependency 'jasmine-core', ">= 1.2.0"
s.add_development_dependency 'anchorman'

s.add_dependency 'jasmine-core', "~> 1.3.1"
s.add_dependency 'rack', '~> 1.0'
s.add_dependency 'rspec', '>= 1.3.1'
s.add_dependency 'selenium-webdriver', '>= 0.1.3'
Expand Down
2 changes: 0 additions & 2 deletions lib/generators/jasmine/install/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ Example:

This will create:
spec/javascripts/support/jasmine.yml
spec/javascripts/support/jasmine_config.rb
spec/javascripts/support/jasmine_runner.rb
spec/javascripts/helpers/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Use this file to set/override Jasmine configuration options
#You can remove it if you don't need it.
#This file is loaded *after* jasmine.yml is interpreted.
#
#Example: using a different boot file.
#Jasmine.configure do |config|
# @config.boot_dir = '/absolute/path/to/boot_dir'
# @config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
#end
#

19 changes: 17 additions & 2 deletions lib/jasmine.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
jasmine_files = ['base',
'dependencies',
'core_configuration',
'configuration',
'config',
'application',
'server',
'selenium_driver',
'spec_builder',
'rspec_formatter',
'command_line_tool',
'page']
'page',
'path_mapper',
'asset_pipeline_utility',
'asset_pipeline_mapper',
'asset_expander',
'results_processor',
'results',
'path_expander',
'yaml_config_parser',
File.join('runners', 'http')]

jasmine_files.each do |file|
require File.join('jasmine', file)
end
# jasmine_rack_files.each do |file|
# require File.join('rack', 'jasmine', file)
# end

require File.join('jasmine', "railtie") if Jasmine::Dependencies.rails3?

Expand Down
21 changes: 21 additions & 0 deletions lib/jasmine/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rack'
require 'rack/utils'
require 'jasmine-core'
require 'rack/jasmine/runner'
require 'rack/jasmine/focused_suite'
require 'rack/jasmine/cache_control'
require 'ostruct'

module Jasmine
class Application
def self.app(config, builder = Rack::Builder.new)
config.rack_apps.each do |(app, config_block)|
builder.use(app, &config_block)
end
config.rack_path_map.each do |path, handler|
builder.map(path) { run handler.call }
end
builder
end
end
end
18 changes: 18 additions & 0 deletions lib/jasmine/asset_expander.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Jasmine
class AssetExpander
def initialize(bundled_asset_factory, asset_path_for)
@bundled_asset_factory = bundled_asset_factory
@asset_path_for = asset_path_for
end

def expand(src_dir, src_path)
pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')
bundled_asset = @bundled_asset_factory.call(pathname, 'js')
return nil unless bundled_asset

bundled_asset.to_a.map do |asset|
"/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true"
end.flatten
end
end
end
16 changes: 16 additions & 0 deletions lib/jasmine/asset_pipeline_mapper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Jasmine
class AssetPipelineMapper

def initialize(config, asset_expander)
@config = config
@asset_expander = asset_expander
end

def map_src_paths(src_paths)
src_paths.map do |src_path|
@asset_expander.call(@config.src_dir, src_path) || src_path
end.flatten.uniq
end

end
end
19 changes: 19 additions & 0 deletions lib/jasmine/asset_pipeline_utility.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Jasmine
class AssetPipelineUtility
def self.bundled_asset_factory(pathname, ext)
context.asset_paths.asset_for(pathname, 'js')
end

def self.asset_path_for(filepath)
context.asset_path(filepath)
end

def self.context
return @context if @context
@context = ::Rails.application.assets.context_class
@context.extend(::Sprockets::Helpers::IsolatedHelper)
@context.extend(::Sprockets::Helpers::RailsHelper)
end

end
end
6 changes: 5 additions & 1 deletion lib/jasmine/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ def self.wait_for_listener(port, name = "required process", seconds_to_wait = 20
end

def self.runner_filepath
File.expand_path(File.join(File.dirname(__FILE__), "runner.rb"))
File.expand_path(File.join(File.dirname(__FILE__), "run_specs.rb"))
end

def self.runner_template
File.read(File.join(File.dirname(__FILE__), "run.html.erb"))
end

def self.root(*paths)
File.expand_path(File.join(File.dirname(__FILE__), *paths))
end

end
27 changes: 11 additions & 16 deletions lib/jasmine/command_line_tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,18 @@ def process(argv)
copy_unless_exists('jasmine-example/spec/PlayerSpec.js', 'spec/javascripts/PlayerSpec.js')
copy_unless_exists('jasmine-example/spec/SpecHelper.js', 'spec/javascripts/helpers/SpecHelper.js')

rails_tasks_dir = dest_path('lib/tasks')
if File.exist?(rails_tasks_dir)
copy_unless_exists('lib/tasks/jasmine.rake')
copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml')
else
copy_unless_exists('spec/javascripts/support/jasmine.yml')
require 'rake'
write_mode = 'w'
if File.exist?(dest_path('Rakefile'))
load dest_path('Rakefile')
write_mode = 'a'
end
copy_unless_exists('spec/javascripts/support/jasmine.yml')
copy_unless_exists('spec/javascripts/support/jasmine_helper.rb')
require 'rake'
write_mode = 'w'
if File.exist?(dest_path('Rakefile'))
load dest_path('Rakefile')
write_mode = 'a'
end

unless Rake::Task.task_defined?('jasmine')
File.open(dest_path('Rakefile'), write_mode) do |f|
f.write("\n" + File.read(template_path('lib/tasks/jasmine.rake')))
end
unless Rake::Task.task_defined?('jasmine')
File.open(dest_path('Rakefile'), write_mode) do |f|
f.write("\n" + File.read(template_path('lib/tasks/jasmine.rake')))
end
end
File.open(template_path('INSTALL'), 'r').each_line do |line|
Expand Down
Loading

0 comments on commit e4c981f

Please sign in to comment.