forked from sumitngupta/jasmine-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored jasmine command line tool.
Added spec for jasmine command line tool.
- Loading branch information
Lee Byrd & Christian Williams
committed
Jun 25, 2010
1 parent
920e918
commit 183ad8f
Showing
12 changed files
with
149 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
require 'rubygems' | ||
require 'rake' | ||
|
||
def cwd | ||
File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
end | ||
|
||
def expand(*paths) | ||
File.expand_path(File.join(*paths)) | ||
end | ||
|
||
def template_path(filepath) | ||
expand(cwd, File.join("generators/jasmine/templates", filepath)) | ||
end | ||
|
||
def dest_path(filepath) | ||
expand(Dir.pwd, filepath) | ||
end | ||
|
||
def copy_unless_exists(relative_path, dest_path = nil) | ||
unless File.exist?(dest_path(relative_path)) | ||
File.copy(template_path(relative_path), dest_path(dest_path || relative_path)) | ||
end | ||
end | ||
|
||
if ARGV[0] == 'init' | ||
require 'ftools' | ||
File.makedirs('spec/javascripts') | ||
File.makedirs('spec/javascripts/support') | ||
File.makedirs('spec/javascripts/helpers') | ||
|
||
copy_unless_exists('spec/javascripts/helpers/SpecHelper.js') | ||
copy_unless_exists('spec/javascripts/ExampleSpec.js') | ||
copy_unless_exists('spec/javascripts/support/jasmine_runner.rb') | ||
|
||
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') | ||
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(File.read(template_path('lib/tasks/jasmine.rake'))) | ||
end | ||
end | ||
end | ||
File.open(template_path('INSTALL'), 'r').each_line do |line| | ||
puts line | ||
end | ||
end | ||
require 'rubygems' | ||
require 'jasmine' | ||
|
||
Jasmine::CommandLineTool.new.process ARGV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1 @@ | ||
namespace :jasmine do | ||
task :require do | ||
require 'jasmine' | ||
end | ||
|
||
desc "Run continuous integration tests" | ||
task :ci => "jasmine:require" do | ||
require "spec" | ||
require 'spec/rake/spectask' | ||
|
||
Spec::Rake::SpecTask.new(:jasmine_continuous_integration_runner) do |t| | ||
t.spec_opts = ["--color", "--format", "specdoc"] | ||
t.verbose = true | ||
t.spec_files = ['spec/javascripts/support/jasmine_runner.rb'] | ||
end | ||
Rake::Task["jasmine_continuous_integration_runner"].invoke | ||
end | ||
|
||
task :server => "jasmine:require" do | ||
jasmine_config_overrides = 'spec/javascripts/support/jasmine_config.rb' | ||
require jasmine_config_overrides if File.exists?(jasmine_config_overrides) | ||
|
||
puts "your tests are here:" | ||
puts " http://localhost:8888/" | ||
|
||
Jasmine::Config.new.start_server | ||
end | ||
end | ||
|
||
desc "Run specs via server" | ||
task :jasmine => ['jasmine:server'] | ||
load 'jasmine/tasks/jasmine.rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
# - dist/**/*.js | ||
# | ||
src_files: | ||
- public/javascripts/**/*.js | ||
|
||
# stylesheets | ||
# | ||
|
Submodule jasmine
updated
from ed80a0 to 7a69d6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
module Jasmine | ||
class CommandLineTool | ||
def cwd | ||
File.expand_path(File.join(File.dirname(__FILE__), '../..')) | ||
end | ||
|
||
def expand(*paths) | ||
File.expand_path(File.join(*paths)) | ||
end | ||
|
||
def template_path(filepath) | ||
expand(cwd, File.join("generators/jasmine/templates", filepath)) | ||
end | ||
|
||
def dest_path(filepath) | ||
expand(Dir.pwd, filepath) | ||
end | ||
|
||
def copy_unless_exists(relative_path, dest_path = nil) | ||
unless File.exist?(dest_path(relative_path)) | ||
File.copy(template_path(relative_path), dest_path(dest_path || relative_path)) | ||
end | ||
end | ||
|
||
def process(argv) | ||
if argv[0] == 'init' | ||
require 'ftools' | ||
File.makedirs('public/javascripts') | ||
File.makedirs('spec/javascripts') | ||
File.makedirs('spec/javascripts/support') | ||
File.makedirs('spec/javascripts/helpers') | ||
|
||
copy_unless_exists('jasmine-example/src/Player.js', 'public/javascripts/Player.js') | ||
copy_unless_exists('jasmine-example/src/Song.js', 'public/javascripts/Song.js') | ||
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') | ||
copy_unless_exists('spec/javascripts/support/jasmine_runner.rb') | ||
|
||
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') | ||
write_mode = 'w' | ||
if File.exist?(dest_path('Rakefile')) | ||
load dest_path('Rakefile') | ||
write_mode = 'a' | ||
end | ||
|
||
require 'rake' | ||
unless Rake::Task.task_defined?('jasmine') | ||
File.open(dest_path('Rakefile'), write_mode) do |f| | ||
f.write(File.read(template_path('lib/tasks/jasmine.rake'))) | ||
end | ||
end | ||
end | ||
File.open(template_path('INSTALL'), 'r').each_line do |line| | ||
puts line | ||
end | ||
else | ||
puts "unknown command #{argv}" | ||
puts "Usage: jasmine init" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace :jasmine do | ||
task :require do | ||
require 'jasmine' | ||
end | ||
|
||
desc "Run continuous integration tests" | ||
task :ci => "jasmine:require" do | ||
require "spec" | ||
require 'spec/rake/spectask' | ||
|
||
Spec::Rake::SpecTask.new(:jasmine_continuous_integration_runner) do |t| | ||
t.spec_opts = ["--color", "--format", "specdoc"] | ||
t.verbose = true | ||
t.spec_files = ['spec/javascripts/support/jasmine_runner.rb'] | ||
end | ||
Rake::Task["jasmine_continuous_integration_runner"].invoke | ||
end | ||
|
||
task :server => "jasmine:require" do | ||
jasmine_config_overrides = 'spec/javascripts/support/jasmine_config.rb' | ||
require jasmine_config_overrides if File.exists?(jasmine_config_overrides) | ||
|
||
puts "your tests are here:" | ||
puts " http://localhost:8888/" | ||
|
||
Jasmine::Config.new.start_server | ||
end | ||
end | ||
|
||
desc "Run specs via server" | ||
task :jasmine => ['jasmine:server'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) | ||
|
||
def create_temp_dir | ||
tmp = File.join(Dir.tmpdir, 'jasmine-gem-test') | ||
FileUtils.rm_r(tmp, :force => true) | ||
FileUtils.mkdir(tmp) | ||
tmp | ||
end | ||
|
||
describe "Jasmine command line tool" do | ||
before :each do | ||
@old_dir = Dir::pwd | ||
@tmp = create_temp_dir | ||
Dir::chdir @tmp | ||
end | ||
|
||
after :each do | ||
Dir::chdir @old_dir | ||
end | ||
|
||
it "should create files on init" do | ||
Jasmine::CommandLineTool.new.process ["init"] | ||
|
||
my_jasmine_lib = File.expand_path(File.join(File.dirname(__FILE__), "../lib")) | ||
bootstrap = "$:.unshift('#{my_jasmine_lib}')" | ||
|
||
ci_output = `rake -E \"#{bootstrap}\" --trace jasmine:ci` | ||
ci_output.should =~ (/[1-9][0-9]* examples, 0 failures/) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters