forked from jasmine/jasmine-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
51 lines (39 loc) · 1.54 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/lib")
require 'bundler'
Bundler::GemHelper.install_tasks
require 'jasmine'
require 'rspec'
require 'rspec/core/rake_task'
desc 'Run all examples'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
task :spec => %w(jasmine:copy_examples_to_gem)
task :default => :spec
namespace :jasmine do
require 'jasmine-core'
task :server do
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) } }
config.jasmine_port = ENV['JASMINE_PORT'] || 8888
end
config = Jasmine.config
server = Jasmine::Server.new(config.jasmine_port, Jasmine::Application.app(config))
server.start
puts 'your tests are here:'
puts " http://localhost:#{config.jasmine_port}/"
end
desc 'Copy examples from Jasmine JS to the gem'
task :copy_examples_to_gem do
require 'fileutils'
# copy jasmine's example tree into our generator templates dir
FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
FileUtils.cp_r(File.join(Jasmine::Core.path, 'example'), 'generators/jasmine/templates/jasmine-example', :preserve => true)
end
end
desc 'Run specs via server'
task :jasmine => %w(jasmine:server)