Skip to content

Commit

Permalink
update example to work with jasmine 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ike18t committed Feb 26, 2015
1 parent cbc561f commit dce80f7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions examples/jasmine_config.rb → examples/jasmine.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#
# spec/javascripts/support/jasmine_config.rb
# spec/javascripts/support/jasmine.rb
#
require 'rack/coffee_compiler'

module Jasmine
class Config

class Configuration
alias_method :old_js_files, :js_files

def js_files(spec_filter = nil)
Expand All @@ -14,14 +13,17 @@ def js_files(spec_filter = nil)
filename.sub(/\.coffee/, '.js')
end
end
end
end

def start_server(port=8888)
module Jasmine
class Server
def start
# We can't access the RAILS_ROOT constant from here
root = File.expand_path(File.join(File.dirname(__FILE__), '../../..'))

config = self

app = Rack::Builder.new do
config = Jasmine.config
@application = Rack::Builder.new do
# Compiler for your specs
use Rack::CoffeeCompiler,
:source_dir => File.join(root, 'spec/javascripts'),
Expand All @@ -32,13 +34,13 @@ def start_server(port=8888)
:source_dir => File.join(root, 'public/javascripts'),
:url => '/public/javascripts'

run Jasmine.app(config)
run Jasmine::Application.app(config)
end

server = Rack::Server.new(:Port => port, :AccessLog => [])
server = Rack::Server.new(@rack_options.merge(:Port => @port, :AccessLog => []))
# workaround for Rack bug, when Rack > 1.2.1 is released Rack::Server.start(:app => Jasmine.app(self)) will work
server.instance_variable_set(:@app, app)
server.instance_variable_set(:@app, @application)
server.start
end
end
end
end

0 comments on commit dce80f7

Please sign in to comment.