From 2efb25a894e913e4dad937935b9288c75520c6cf Mon Sep 17 00:00:00 2001 From: Jason Morrison Date: Wed, 28 Mar 2012 18:03:17 +0700 Subject: [PATCH 01/53] Require Rails from rspec when mounting asset pipeline --- lib/jasmine/tasks/jasmine.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jasmine/tasks/jasmine.rake b/lib/jasmine/tasks/jasmine.rake index 5093369e..4fc88a03 100644 --- a/lib/jasmine/tasks/jasmine.rake +++ b/lib/jasmine/tasks/jasmine.rake @@ -27,7 +27,7 @@ namespace :jasmine do t.rspec_opts = ["--colour", "--format", ENV['JASMINE_SPEC_FORMAT'] || "progress"] t.verbose = true if Jasmine::Dependencies.rails_3_asset_pipeline? - t.ruby_opts = ["-r #{File.expand_path(File.join(::Rails.root, 'config', 'environment'))}"] + t.rspec_opts += ["-r #{File.expand_path(File.join(::Rails.root, 'config', 'environment'))}"] end t.pattern = [Jasmine.runner_filepath] end From 4361bb38a22c41395f2474391c0627d14764a94a Mon Sep 17 00:00:00 2001 From: ragaskar Date: Tue, 10 Jul 2012 20:54:17 -0700 Subject: [PATCH 02/53] Replace ruby-debug19 with debugger gem. - 1.9.3 compatible; much simpler. Probably won't work with older rubies, but good enough for most development. --- Gemfile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index b36c6989..1afd28ab 100644 --- a/Gemfile +++ b/Gemfile @@ -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 From 27dceeadf629876e56d81d90af5d884544913142 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Tue, 10 Jul 2012 20:54:24 -0700 Subject: [PATCH 03/53] Add dependency on rspec < 2.11.0 - Jasmine is currently incompatible with rspec 2.11.0 due to some DSL changes. The rspec formatting is being rewritten, but for now we'll need rspec <= 2.10.0 --- Gemfile | 3 +++ jasmine.gemspec | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1afd28ab..a582a4fc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ source "http://rubygems.org" gemspec +#bundle fails on the rspec gemspec requirement without this line +gem 'rspec', '< 2.11' + unless ENV["TRAVIS"] group :debug do gem 'debugger' diff --git a/jasmine.gemspec b/jasmine.gemspec index 361296f0..03dd8731 100644 --- a/jasmine.gemspec +++ b/jasmine.gemspec @@ -68,6 +68,6 @@ Gem::Specification.new do |s| s.add_dependency 'jasmine-core', ">= 1.2.0" s.add_dependency 'rack', '~> 1.0' - s.add_dependency 'rspec', '>= 1.3.1' + s.add_dependency 'rspec', '>= 1.3.1', '< 2.11.0' s.add_dependency 'selenium-webdriver', '>= 0.1.3' end From 818718ac7bc6b10b7953bf6809318532f10df95a Mon Sep 17 00:00:00 2001 From: ragaskar Date: Fri, 22 Jun 2012 07:17:08 -0700 Subject: [PATCH 04/53] Colorize rspec - When used with rspec2 --- .rspec | 1 + 1 file changed, 1 insertion(+) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..4e1e0d2f --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color From 8642ce58a9bc8fbe598244d752bfaccc63eca079 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Sat, 30 Jun 2012 19:32:24 -0700 Subject: [PATCH 05/53] Fix runner source reloading; config refactoring. - Remove shim for Page; should fix problem where new files aren't picked up by Jasmine runner. - YAML parsing is a separate issue, temp. moved to UserConfig - Main config interface needs to be further reduced. - Config shouldn't be start/stopping servers; move to SpecBuilder for now. - Page now responsible for adapting the context to the rendering solution - Privatize what we can in SpecBuilder. - Move ENV var specs to spec_builder_spec and temporarily pend; poor tests anyways, should be fixed. --- lib/jasmine.rb | 1 + lib/jasmine/config.rb | 165 ++------------ lib/jasmine/page.rb | 2 +- lib/jasmine/run.html.erb | 1 + lib/jasmine/runner.rb | 2 +- lib/jasmine/server.rb | 7 +- lib/jasmine/spec_builder.rb | 173 +++++++++------ lib/jasmine/user_config.rb | 109 ++++++++++ spec/config_spec.rb | 357 ++++++------------------------- spec/jasmine_self_test_config.rb | 2 +- spec/jasmine_self_test_spec.rb | 2 +- spec/page_spec.rb | 2 +- spec/server_spec.rb | 22 +- spec/spec_builder_spec.rb | 89 ++++++++ spec/user_config_spec.rb | 257 ++++++++++++++++++++++ 15 files changed, 667 insertions(+), 524 deletions(-) create mode 100644 lib/jasmine/user_config.rb create mode 100644 spec/spec_builder_spec.rb create mode 100644 spec/user_config_spec.rb diff --git a/lib/jasmine.rb b/lib/jasmine.rb index acf7b902..df1651a1 100644 --- a/lib/jasmine.rb +++ b/lib/jasmine.rb @@ -1,6 +1,7 @@ jasmine_files = ['base', 'dependencies', 'config', + 'user_config', 'server', 'selenium_driver', 'spec_builder', diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index 28a12afa..0fe61b81 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -1,172 +1,47 @@ module Jasmine class Config - require 'yaml' - require 'erb' - - def browser - ENV["JASMINE_BROWSER"] || 'firefox' - end - - def jasmine_host - ENV["JASMINE_HOST"] || 'http://localhost' - end - - def jasmine_port - ENV["JASMINE_PORT"] || Jasmine::find_unused_port - end - - def start_server(port = 8888) - if defined? Rack::Server # Rack ~>1.0 compatibility - server = Rack::Server.new(:Port => port, :AccessLog => []) - server.instance_variable_set(:@app, Jasmine.app(self)) # workaround for Rack bug, when Rack > 1.2.1 is released Rack::Server.start(:app => Jasmine.app(self)) will work - server.start - else - handler = Rack::Handler.get('webrick') - handler.run(Jasmine.app(self), :Port => port, :AccessLog => []) - end - end - - def start - start_jasmine_server - @client = Jasmine::SeleniumDriver.new(browser, "#{jasmine_host}:#{@jasmine_server_port}/") - @client.connect - end - - def stop - @client.disconnect - end - - def start_jasmine_server - require 'json' - @jasmine_server_port = jasmine_port - t = Thread.new do - begin - start_server(@jasmine_server_port) - rescue ChildProcess::TimeoutError; end - #ignore bad exits - end - t.abort_on_exception = true - Jasmine::wait_for_listener(@jasmine_server_port, "jasmine server") - puts "jasmine server started." - end - - def windows? - require 'rbconfig' - ::RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ - end - - def run - begin - start - puts "servers are listening on their ports -- running the test script..." - tests_passed = @client.run - ensure - stop - end - return tests_passed - end - - def eval_js(script) - @client.eval_js(script) - end - - def json_generate(obj) - @client.json_generate(obj) - end - - def match_files(dir, patterns) - dir = File.expand_path(dir) - negative, positive = patterns.partition {|pattern| /^!/ =~ pattern} - chosen, negated = [positive, negative].collect do |patterns| - patterns.collect do |pattern| - matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,''))) - matches.empty? && !(pattern =~ /\*|^\!/) ? pattern : matches.collect {|f| f.sub("#{dir}/", "")}.sort - end.flatten.uniq - end - chosen - negated + def initialize(user_config) + @user_config = user_config end - def simple_config - config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false - config || {} + def css_files + @user_config.jasmine_stylesheets + @user_config.user_stylesheets end - - def spec_path - "/__spec__" + def jasmine_files + @user_config.jasmine_javascripts end - def root_path - "/__root__" + def js_files + @user_config.js_files end - def js_files(spec_filter = nil) - spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter]) - src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) } - end - - def css_files - stylesheets.collect {|f| "/" + f } + def spec_files + @user_config.spec_files end def spec_files_full_paths - spec_files.collect {|spec_file| File.join(spec_dir, spec_file) } - end - - def project_root - Dir.pwd - end - - def simple_config_file - File.join(project_root, 'spec/javascripts/support/jasmine.yml') + @user_config.spec_files_full_paths end - def src_dir - if simple_config['src_dir'] - File.join(project_root, simple_config['src_dir']) - else - project_root - end + def spec_path + @user_config.spec_path end def spec_dir - if simple_config['spec_dir'] - File.join(project_root, simple_config['spec_dir']) - else - File.join(project_root, 'spec/javascripts') - end + @user_config.spec_dir end - def helpers - if simple_config['helpers'] - match_files(spec_dir, simple_config['helpers']) - else - match_files(spec_dir, ["helpers/**/*.js"]) - end - end - - def src_files - if simple_config['src_files'] - match_files(src_dir, simple_config['src_files']) - else - [] - end + def src_dir + @user_config.src_dir end - def spec_files - if simple_config['spec_files'] - match_files(spec_dir, simple_config['spec_files']) - else - match_files(spec_dir, ["**/*[sS]pec.js"]) - end + def project_root + @user_config.project_root end - def stylesheets - if simple_config['stylesheets'] - match_files(src_dir, simple_config['stylesheets']) - else - [] - end + def root_path + @user_config.root_path end end end diff --git a/lib/jasmine/page.rb b/lib/jasmine/page.rb index 0d8c2325..b18c7219 100644 --- a/lib/jasmine/page.rb +++ b/lib/jasmine/page.rb @@ -5,7 +5,7 @@ def initialize(context) end def render - ERB.new(::Jasmine.runner_template).result(@context) + ERB.new(::Jasmine.runner_template).result(@context.instance_eval { binding }) end end end diff --git a/lib/jasmine/run.html.erb b/lib/jasmine/run.html.erb index 00436d49..030d1872 100644 --- a/lib/jasmine/run.html.erb +++ b/lib/jasmine/run.html.erb @@ -13,6 +13,7 @@ <% end %> - <% end %> - - - <% js_files.each do |js_file| %> <% end %> diff --git a/lib/jasmine/run_specs.rb b/lib/jasmine/run_specs.rb index 33f34269..5df89f95 100644 --- a/lib/jasmine/run_specs.rb +++ b/lib/jasmine/run_specs.rb @@ -2,18 +2,22 @@ require 'rubygems' require 'jasmine' -jasmine_config_overrides = File.expand_path(File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine_config.rb')) -require jasmine_config_overrides if File.exist?(jasmine_config_overrides) if Jasmine::Dependencies.rspec2? require 'rspec' else require 'spec' end -jasmine_runner_config = Jasmine::RunnerConfig.new -server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config)) -client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url) +jasmine_yml = File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine.yml') +if File.exist?(jasmine_yml) +end + +Jasmine.load_configuration_from_yaml + +config = Jasmine.config +server = Jasmine::Server.new(config.port, Jasmine::Application.app(config)) +driver = Jasmine::SeleniumDriver.new(config.browser, "#{config.host}:#{config.port}/") t = Thread.new do begin server.start @@ -22,11 +26,11 @@ # # ignore bad exits end t.abort_on_exception = true -Jasmine::wait_for_listener(jasmine_runner_config.port, "jasmine server") +Jasmine::wait_for_listener(config.port, "jasmine server") puts "jasmine server started." -results_processor = Jasmine::ResultsProcessor.new(jasmine_runner_config) -results = Jasmine::Runners::HTTP.new(client, results_processor, jasmine_runner_config.result_batch_size).run +results_processor = Jasmine::ResultsProcessor.new(config) +results = Jasmine::Runners::HTTP.new(driver, results_processor, config.result_batch_size).run formatter = Jasmine::RspecFormatter.new formatter.format_results(results) diff --git a/lib/jasmine/runner_config.rb b/lib/jasmine/runner_config.rb deleted file mode 100644 index 8293cfac..00000000 --- a/lib/jasmine/runner_config.rb +++ /dev/null @@ -1,71 +0,0 @@ -module Jasmine - class RunnerConfig - def initialize(config = Jasmine::Config.new) - @config = config - end - - def css_files - @config.jasmine_stylesheets + @config.user_stylesheets - end - - def jasmine_files - @config.jasmine_javascripts - end - - def js_files - @config.js_files - end - - def spec_files - @config.spec_files - end - - def spec_files_full_paths - @config.spec_files_full_paths - end - - def spec_path - @config.spec_path - end - - def spec_dir - @config.spec_dir - end - - def src_dir - @config.src_dir - end - - def project_root - @config.project_root - end - - def root_path - @config.root_path - end - - def browser - ENV["JASMINE_BROWSER"] || 'firefox' - end - - def port - @config.port - end - - def jasmine_server_url - "#{@config.jasmine_host}:#{@config.port}/" - end - - def src_mapper=(context) - @config.src_mapper = context - end - - def src_mapper - @config.src_mapper - end - - def result_batch_size - ENV["JASMINE_RESULT_BATCH_SIZE"] ? ENV["JASMINE_RESULT_BATCH_SIZE"].to_i : 50 - end - end -end diff --git a/lib/jasmine/server.rb b/lib/jasmine/server.rb index ce6f0010..ac12bb42 100644 --- a/lib/jasmine/server.rb +++ b/lib/jasmine/server.rb @@ -1,6 +1,6 @@ module Jasmine class Server - def initialize(port = 8888, application = Jasmine::Application.app) + def initialize(port = 8888, application = nil) @port = port @application = application end diff --git a/lib/jasmine/tasks/jasmine.rake b/lib/jasmine/tasks/jasmine.rake index 6219ad60..76a121fc 100644 --- a/lib/jasmine/tasks/jasmine.rake +++ b/lib/jasmine/tasks/jasmine.rake @@ -42,13 +42,12 @@ namespace :jasmine do end task :server => "jasmine:require" do - jasmine_config_overrides = File.join(Jasmine::Config.new.project_root, 'spec', 'javascripts' ,'support' ,'jasmine_config.rb') - require jasmine_config_overrides if File.exist?(jasmine_config_overrides) - port = ENV['JASMINE_PORT'] || 8888 puts "your tests are here:" puts " http://localhost:#{port}/" - Jasmine::Server.new(port).start + Jasmine.load_configuration_from_yaml + app = Jasmine::Application.app(Jasmine.config) + Jasmine::Server.new(port, app).start end end diff --git a/lib/jasmine/yaml_config_parser.rb b/lib/jasmine/yaml_config_parser.rb new file mode 100644 index 00000000..017b2faf --- /dev/null +++ b/lib/jasmine/yaml_config_parser.rb @@ -0,0 +1,41 @@ +module Jasmine + class YamlConfigParser + def initialize(path, pwd, path_expander = lambda {}, yaml_loader = lambda {}) + @path = path + @path_expander = path_expander + @pwd = pwd + @yaml_loader = yaml_loader + end + + def src_dir + return @pwd unless loaded_yaml['src_dir'] + File.join(@pwd, loaded_yaml['src_dir']) + end + + def spec_dir + return File.join(@pwd, 'spec', 'javascripts') unless loaded_yaml['spec_dir'] + File.join(@pwd, loaded_yaml['spec_dir']) + end + + def src_files + @path_expander.call(src_dir, loaded_yaml['src_files'] || []) + end + + def spec_files + @path_expander.call(spec_dir, loaded_yaml['spec_files'] || []) + end + + def helpers + @path_expander.call(spec_dir, loaded_yaml['helpers'] || []) + end + + def css_files + @path_expander.call(src_dir, loaded_yaml['stylesheets'] || []) + end + + private + def loaded_yaml + @yaml_loader.call(@path) + end + end +end diff --git a/lib/rack/jasmine/redirect.rb b/lib/rack/jasmine/redirect.rb deleted file mode 100644 index a3103c89..00000000 --- a/lib/rack/jasmine/redirect.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Rack - module Jasmine - - class Redirect - def initialize(url) - @url = url - end - - def call(env) - [ - 302, - { 'Location' => @url }, - [] - ] - end - end - - end -end - diff --git a/spec/application_integration_spec.rb b/spec/application_integration_spec.rb new file mode 100644 index 00000000..62067ad2 --- /dev/null +++ b/spec/application_integration_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "Jasmine::Application" do + + it "includes no-cache headers for specs" do + pending + get "/__spec__/example_spec.js" + last_response.headers.should have_key("Cache-Control") + last_response.headers["Cache-Control"].should == "max-age=0, private, must-revalidate" + last_response.headers['Pragma'].each do |key| + last_response.headers[key].should == 'no-cache' + end + end + +end diff --git a/spec/application_spec.rb b/spec/application_spec.rb index ead0da10..434fbd9c 100644 --- a/spec/application_spec.rb +++ b/spec/application_spec.rb @@ -1,99 +1,44 @@ require 'spec_helper' -require 'rack/test' -describe "Jasmine::Application" do - include Rack::Test::Methods - - def app - @root = File.join(File.dirname(__FILE__)) - runner_config = double("config", - :project_root => @root, - :spec_dir => File.join(@root, "fixture", "spec"), - :spec_path => "/__spec__", - :root_path => "/__root__", - :css_files => [], - :jasmine_files => [], - :js_files => ["path/file1.js", "path/file2.js"], - :src_dir => File.join(@root, "fixture", "src"), - :src_files => ["file1.js"], - :spec_files => ["example_spec.js"]) - Jasmine::Application.app(runner_config) - end - - it "includes no-cache headers for specs" do - get "/__spec__/example_spec.js" - last_response.headers.should have_key("Cache-Control") - last_response.headers["Cache-Control"].should == "max-age=0, private, must-revalidate" - end - - it "should serve static files from spec dir under __spec__" do - get "/__spec__/example_spec.js" - last_response.status.should == 200 - last_response.content_type.should == "application/javascript" - last_response.body.should == File.read(File.join(@root, "fixture/spec/example_spec.js")) - end - - it "should serve static files from root dir under __root__" do - get "/__root__/fixture/src/example.js" - last_response.status.should == 200 - last_response.content_type.should == "application/javascript" - last_response.body.should == File.read(File.join(@root, "fixture/src/example.js")) - end - - it "should serve static files from src dir under /" do - get "/example.js" - last_response.status.should == 200 - last_response.content_type.should == "application/javascript" - last_response.body.should == File.read(File.join(@root, "fixture/src/example.js")) - end - - it "should serve Jasmine static files under /__JASMINE_ROOT__/" do - get "/__JASMINE_ROOT__/jasmine.css" - last_response.status.should == 200 - last_response.content_type.should == "text/css" - last_response.body.should == File.read(File.join(Jasmine::Core.path, "jasmine.css")) - end - - it "should serve focused suites when prefixing spec files with /__suite__/" do - pending "Temporarily removing this feature (maybe permanent)" - Dir.stub!(:glob).and_return { |glob_string| [glob_string] } - get "/__suite__/file2.js" - last_response.status.should == 200 - last_response.content_type.should == "text/html" - last_response.body.should include("\"/__spec__/file2.js") - end - - it "should redirect /run.html to /" do - get "/run.html" - last_response.status.should == 302 - last_response.location.should == "/" - end - - it "should 404 non-existent files" do - get "/some-non-existent-file" - last_response.should be_not_found - end - - describe "/ page" do - it "should load each js file in order" do - get "/" - last_response.status.should == 200 - last_response.body.should include("path/file1.js") - last_response.body.should include("path/file2.js") - end +#Rspec 1 doesn't correctly pass blocks to stubs, so skip (covered by integration tests) +#https://groups.google.com/forum/?fromgroups=#!topic/rspec/XT7paH2asCo + +if Jasmine::Dependencies.rspec2? + describe "Jasmine::Application" do + it "should map paths provided by the config" do + handler1 = double(:handler1) + handler2 = double(:handler2) + app1 = double(:app1) + app2 = double(:app2) + rack_path_map = {"/foo" => lambda { handler1 }, "/bar" => lambda { handler2 }} + config = double(:config, :rack_path_map => rack_path_map, :rack_apps => []) + builder = double("Rack::Builder.new") + #Rack::Builder instance evals, so builder.run is invalid syntax, + #this is the only way to stub out the 'run' dsl it gives to the block. + Jasmine::Application.stub(:run).with(handler1).and_return(app1) + Jasmine::Application.stub(:run).with(handler2).and_return(app2) + + builder.should_receive(:map).twice do |path, &app| + if path == '/foo' + app.call.should == app1 + elsif path == '/bar' + app.call.should == app2 + else + raise "Unexpected path passed" + end + end - it "should return an empty 200 for HEAD requests to /" do - head "/" - last_response.status.should == 200 - last_response.headers['Content-Type'].should == 'text/html' - last_response.body.should == '' + Jasmine::Application.app(config, builder).should == builder end - - it "should tell the browser not to cache any assets" do - head "/" - ['Pragma'].each do |key| - last_response.headers[key].should == 'no-cache' - end + it "should run rack apps provided by the config" do + app1 = double(:app1) + app2 = double(:app2) + block = lambda { "foo" } + config = double(:config, :rack_path_map => [], :rack_apps => [[app1, nil], [app2, block]]) + builder = double("Rack::Builder.new") + builder.should_receive(:use).with(app1) + builder.should_receive(:use).with(app2, &block) + Jasmine::Application.app(config, builder).should == builder end end end diff --git a/spec/base_spec.rb b/spec/base_spec.rb new file mode 100644 index 00000000..ab4afe98 --- /dev/null +++ b/spec/base_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Jasmine do + it "should provide the root path" do + File.stub(:dirname).and_return('lib/jasmine') + File.should_receive(:expand_path) { |path| path } + Jasmine.root.should == 'lib/jasmine' + end + it "should append passed file paths" do + File.stub(:dirname).and_return('lib/jasmine') + File.should_receive(:expand_path) { |path| path } + Jasmine.root('subdir1', 'subdir2').should == File.join('lib/jasmine', 'subdir1', 'subdir2') + end +end diff --git a/spec/config_spec.rb b/spec/config_spec.rb deleted file mode 100644 index 323dc2dd..00000000 --- a/spec/config_spec.rb +++ /dev/null @@ -1,309 +0,0 @@ -require 'spec_helper' -require 'selenium-webdriver' - -describe Jasmine::Config do - describe "configuration" do - before :each do - Jasmine::Dependencies.stub(:rails_3_asset_pipeline?) { false } - - temp_dir_before - - Dir::chdir @tmp - dir_name = "test_js_project" - `mkdir -p #{dir_name}` - Dir::chdir dir_name - `#{@root}/bin/jasmine init .` - - @project_dir = Dir.pwd - - @template_dir = File.expand_path(File.join(@root, "generators/jasmine/templates")) - @config = Jasmine::Config.new - end - - after(:each) do - temp_dir_after - end - - describe "defaults" do - it "src_dir uses root when src dir is blank" do - @config.stub!(:project_root).and_return('some_project_root') - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml')) - YAML.stub!(:load).and_return({'src_dir' => nil}) - @config.src_dir.should == 'some_project_root' - end - - it "should use correct default yaml config" do - @config.stub!(:project_root).and_return('some_project_root') - @config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml')) - end - end - - describe "simple_config" do - before(:each) do - @config.stub!(:src_dir).and_return(File.join(@project_dir, ".")) - @config.stub!(:spec_dir).and_return(File.join(@project_dir, "spec/javascripts")) - end - - describe "using default jasmine.yml" do - before(:each) do - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml')) - end - - it "should find the source files" do - @config.src_files.should =~ ['public/javascripts/Player.js', 'public/javascripts/Song.js'] - end - - it "should find the stylesheet files" do - @config.stylesheets.should == [] - end - - it "should find the spec files" do - @config.spec_files.should == ['PlayerSpec.js'] - end - - it "should find any helpers" do - @config.helpers.should == ['helpers/SpecHelper.js'] - end - - it "should build an array of all the JavaScript files to include, source files then spec files" do - @config.js_files.should == [ - '/public/javascripts/Player.js', - '/public/javascripts/Song.js', - '/__spec__/helpers/SpecHelper.js', - '/__spec__/PlayerSpec.js' - ] - end - - it "should allow the js_files to be filtered" do - @config.js_files("PlayerSpec.js").should == [ - '/public/javascripts/Player.js', - '/public/javascripts/Song.js', - '/__spec__/helpers/SpecHelper.js', - '/__spec__/PlayerSpec.js' - ] - end - - it "should report the full paths of the spec files" do - @config.spec_files_full_paths.should == [File.join(@project_dir, 'spec/javascripts/PlayerSpec.js')] - end - end - - it "should parse ERB" do - @config.stub!(:simple_config_file).and_return(File.expand_path(File.join(@root, 'spec', 'fixture','jasmine.erb.yml'))) - Dir.stub!(:glob).and_return { |glob_string| [glob_string] } - @config.src_files.should == ['file0.js', 'file1.js', 'file2.js',] - end - - describe "if jasmine.yml not found" do - before(:each) do - File.stub!(:exist?).and_return(false) - end - - it "should default to loading no source files" do - @config.src_files.should be_empty - end - - it "should default to loading no stylesheet files" do - @config.stylesheets.should be_empty - end - - end - - describe "if jasmine.yml is empty" do - before(:each) do - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml')) - YAML.stub!(:load).and_return(false) - end - - it "should default to loading no source files" do - @config.src_files.should be_empty - end - - it "should default to loading no stylesheet files" do - @config.stylesheets.should be_empty - end - end - - describe "should use the first appearance of duplicate filenames" do - before(:each) do - Dir.stub!(:glob).and_return { |glob_string| [glob_string] } - fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "file2.ext", "file1.ext"] } - @config.stub!(:simple_config).and_return(fake_config) - end - - it "src_files" do - @config.src_files.should == ['file1.ext', 'file2.ext'] - end - - it "stylesheets" do - @config.stylesheets.should == ['file1.ext', 'file2.ext'] - end - - it "spec_files" do - @config.spec_files.should == ['file1.ext', 'file2.ext'] - end - - it "helpers" do - @config.spec_files.should == ['file1.ext', 'file2.ext'] - end - - it "js_files" do - @config.js_files.should == ["/file1.ext", - "/file2.ext", - "/__spec__/file1.ext", - "/__spec__/file2.ext", - "/__spec__/file1.ext", - "/__spec__/file2.ext"] - end - - it "spec_files_full_paths" do - @config.spec_files_full_paths.should == [ - File.expand_path("spec/javascripts/file1.ext", @project_dir), - File.expand_path("spec/javascripts/file2.ext", @project_dir) - ] - end - end - - describe "should permit explicity-declared filenames to pass through regardless of their existence" do - before(:each) do - Dir.stub!(:glob).and_return { |glob_string| [] } - fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file2.ext", "**/*file3.ext"] } - @config.stub!(:simple_config).and_return(fake_config) - end - - it "should contain explicitly files" do - @config.src_files.should == ["file1.ext"] - end - end - - describe "should allow .gitignore style negation (!pattern)" do - before(:each) do - Dir.stub!(:glob).and_return { |glob_string| [glob_string] } - fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file1.ext", "file2.ext"] } - @config.stub!(:simple_config).and_return(fake_config) - end - - it "should not contain negated files" do - @config.src_files.should == ["file2.ext"] - end - end - - it "simple_config stylesheets" do - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml')) - - YAML.stub!(:load).and_return({'stylesheets' => ['foo.css', 'bar.css']}) - Dir.stub!(:glob).and_return { |glob_string| [glob_string] } - - @config.stylesheets.should == ['foo.css', 'bar.css'] - end - - it "using rails jasmine.yml" do - ['public/javascripts/prototype.js', - 'public/javascripts/effects.js', - 'public/javascripts/controls.js', - 'public/javascripts/dragdrop.js', - 'public/javascripts/application.js'].each { |f| `touch #{f}` } - - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml')) - - @config.spec_files.should == ['PlayerSpec.js'] - @config.helpers.should == ['helpers/SpecHelper.js'] - @config.src_files.should == ['public/javascripts/prototype.js', - 'public/javascripts/effects.js', - 'public/javascripts/controls.js', - 'public/javascripts/dragdrop.js', - 'public/javascripts/application.js', - 'public/javascripts/Player.js', - 'public/javascripts/Song.js'] - @config.js_files.should == [ - '/public/javascripts/prototype.js', - '/public/javascripts/effects.js', - '/public/javascripts/controls.js', - '/public/javascripts/dragdrop.js', - '/public/javascripts/application.js', - '/public/javascripts/Player.js', - '/public/javascripts/Song.js', - '/__spec__/helpers/SpecHelper.js', - '/__spec__/PlayerSpec.js', - ] - @config.js_files("PlayerSpec.js").should == [ - '/public/javascripts/prototype.js', - '/public/javascripts/effects.js', - '/public/javascripts/controls.js', - '/public/javascripts/dragdrop.js', - '/public/javascripts/application.js', - '/public/javascripts/Player.js', - '/public/javascripts/Song.js', - '/__spec__/helpers/SpecHelper.js', - '/__spec__/PlayerSpec.js' - ] - end - end - end - - - describe "jasmine_stylesheets" do - it "should return the relative web server path to the core Jasmine css stylesheets" do - #TODO: wrap Jasmine::Core with a class that knows about the core path and the relative mapping. - Jasmine::Core.stub(:css_files).and_return(["my_css_file1.css", "my_css_file2.css"]) - Jasmine::Config.new.jasmine_stylesheets.should == ["/__JASMINE_ROOT__/my_css_file1.css", "/__JASMINE_ROOT__/my_css_file2.css"] - end - end - - describe "jasmine_javascripts" do - it "should return the relative web server path to the core Jasmine css javascripts" do - Jasmine::Core.stub(:js_files).and_return(["my_js_file1.js", "my_js_file2.js"]) - Jasmine::Config.new.jasmine_javascripts.should == ["/__JASMINE_ROOT__/my_js_file1.js", "/__JASMINE_ROOT__/my_js_file2.js"] - end - end - - describe "when the asset pipeline (or any other sprockets environment) is active" do - let(:src_files) { ["assets/some.js", "assets/files.js"] } - let(:mapped_files) { ["some.js", "files.js"] } - let(:mapper) { double("mapper") } - - let(:config) do - Jasmine::Config.new.tap do |config| - #TODO: simple_config should be a passed in hash - config.stub(:simple_config) { { 'src_files' => src_files} } - config.src_mapper = mapper - end - end - - it "should use the mapper to return src_files" do - mapper.should_receive(:files).with(src_files).and_return(mapped_files) - config.src_files.should == mapped_files - end - end - - describe "jasmine_host" do - it "should default to localhost" do - Jasmine::Config.new.jasmine_host.should == 'http://localhost' - end - - it "should use ENV['JASMINE_HOST'] if it exists" do - ENV.stub(:[], "JASMINE_HOST").and_return("foo") - Jasmine::Config.new.jasmine_host.should == 'foo' - end - end - - describe "port" do - it "should find an unused port" do - Jasmine.should_receive(:find_unused_port).and_return('1234') - Jasmine::Config.new.port.should == '1234' - end - - it "should use ENV['JASMINE_PORT'] if it exists" do - ENV.stub(:[], "JASMINE_PORT").and_return("foo") - Jasmine::Config.new.port.should == 'foo' - end - - it "should cache port" do - config = Jasmine::Config.new - Jasmine.stub(:find_unused_port).and_return('1234') - config.port.should == '1234' - Jasmine.stub(:find_unused_port).and_return('4321') - config.port.should == '1234' - end - end -end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb new file mode 100644 index 00000000..3380130b --- /dev/null +++ b/spec/configuration_spec.rb @@ -0,0 +1,163 @@ +require 'spec_helper' + +describe Jasmine::Configuration do + let(:test_mapper1) do + Class.new do + def initialize(config) + @config = config + end + def map_src_paths(paths) + paths.map { |f| "mapped_src/#{f}" } + end + def map_jasmine_paths(paths) + paths.map { |f| "mapped_jasmine/#{f}" } + end + def map_spec_paths(paths) + paths.map { |f| "mapped_spec/#{f}" } + end + def map_boot_paths(paths) + paths.map { |f| "mapped_boot/#{f}" } + end + end + end + let(:test_mapper2) do + Class.new do + def initialize(config) + @config = config + end + def map_src_paths(paths) + paths.map { |f| "#{f}/src" } + end + def map_jasmine_paths(paths) + paths.map { |f| "#{f}/jasmine" } + end + def map_spec_paths(paths) + paths.map { |f| "#{f}/spec" } + end + def map_boot_paths(paths) + paths.map { |f| "#{f}/boot" } + end + end + end + let(:test_mapper3) do + Class.new do + def initialize(config) + @config = config + end + end + end + + describe "returning css files" do + it "returns mapped jasmine_css_files + css_files" do + config = Jasmine::Configuration.new() + config.add_path_mapper(test_mapper1) + config.add_path_mapper(test_mapper2) + config.add_path_mapper(test_mapper3) + config.css_files.should == [] + config.jasmine_css_files = lambda { ["jasmine_css"] } + config.css_files = lambda { ["css"] } + config.css_files.should == ['mapped_jasmine/jasmine_css/jasmine', 'mapped_src/css/src'] + end + end + + describe "returning javascript files" do + it "returns the jasmine core files, then srcs, then specs, then boot" do + config = Jasmine::Configuration.new() + config.add_path_mapper(test_mapper1) + config.add_path_mapper(test_mapper2) + config.add_path_mapper(test_mapper3) + config.js_files.should == [] + config.jasmine_files = lambda { ['jasmine'] } + config.src_files = lambda { ['src'] } + config.boot_files = lambda { ['boot'] } + config.spec_files = lambda { ['spec'] } + config.js_files.should == [ + 'mapped_jasmine/jasmine/jasmine', + 'mapped_src/src/src', + 'mapped_spec/spec/spec', + 'mapped_boot/boot/boot', + ] + end + end + + describe "returning rack map" do + it "permits arbitrary rack app path mapping" do + config = Jasmine::Configuration.new() + result = double + config.add_rack_path('some/path', lambda { result }) + map = config.rack_path_map + map['some/path'].should be + map['some/path'].call.should == result + end + + end + + describe "rack apps" do + it "permits the addition of arbitary rack apps" do + config = Jasmine::Configuration.new() + app = double + config.add_rack_app(app) + config.rack_apps.should == [[app, nil]] + end + it "permits the addition of arbitary rack apps with arbitrary config" do + config = Jasmine::Configuration.new() + app = double + block = lambda { "foo" } + config.add_rack_app(app, &block) + config.rack_apps.should == [[app, block]] + end + end + + describe "port" do + it "returns new port and caches return value" do + config = Jasmine::Configuration.new() + Jasmine.stub(:find_unused_port).and_return('1234') + config.port.should == '1234' + Jasmine.stub(:find_unused_port).and_return('4321') + config.port.should == '1234' + end + it "returns port if configured" do + config = Jasmine::Configuration.new() + config.port = '5678' + Jasmine.stub(:find_unused_port).and_return('1234') + config.port.should == '5678' + end + end + + describe "browser" do + it "should default to firefox" do + Jasmine::Configuration.new().browser.should == 'firefox' + end + + it "returns browser if set" do + config = Jasmine::Configuration.new() + config.browser = 'foo' + config.browser.should == 'foo' + end + end + + describe "result_batch_size" do + it "should default to 50" do + Jasmine::Configuration.new().result_batch_size.should == 50 + end + + it "returns result_batch_size if set" do + config = Jasmine::Configuration.new() + config.result_batch_size = 25 + config.result_batch_size.should == 25 + end + end + + describe "host" do + it "should default to localhost" do + Jasmine::Configuration.new().host.should == 'http://localhost' + end + + it "returns host if set" do + config = Jasmine::Configuration.new() + config.host = 'foo' + config.host.should == 'foo' + end + end +end + diff --git a/spec/fixture/jasmine.erb.yml b/spec/fixture/jasmine.erb.yml deleted file mode 100644 index 3c6b0574..00000000 --- a/spec/fixture/jasmine.erb.yml +++ /dev/null @@ -1,4 +0,0 @@ -src_files: -<% 3.times do |i| %> - - <%= "file#{i}.js" %> -<% end %> \ No newline at end of file diff --git a/spec/fixture/spec/example_spec.js b/spec/fixture/spec/example_spec.js deleted file mode 100644 index 7403e49b..00000000 --- a/spec/fixture/spec/example_spec.js +++ /dev/null @@ -1,5 +0,0 @@ -describe("example_spec", function() { - it("should be here for path loading tests", function() { - expect(true).toBe(true); - } -}) diff --git a/spec/fixture/src/example.js b/spec/fixture/src/example.js deleted file mode 100644 index 83c71184..00000000 --- a/spec/fixture/src/example.js +++ /dev/null @@ -1,3 +0,0 @@ -function Example() { - this.is_here = "for path loading tests"; -} diff --git a/spec/jasmine_self_test_config.rb b/spec/jasmine_self_test_config.rb deleted file mode 100644 index 16a6b334..00000000 --- a/spec/jasmine_self_test_config.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'jasmine' - -class JasmineSelfTestConfig < Jasmine::Config - def project_root - File.expand_path(File.join(File.dirname(__FILE__), "..")) - end - - def src_dir - File.join(project_root, 'src') - end - - def spec_dir - Jasmine::Core.path - end - - def spec_files - Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files - end -end diff --git a/spec/jasmine_self_test_spec.rb b/spec/jasmine_self_test_spec.rb index b9527a15..a8d5a5dc 100644 --- a/spec/jasmine_self_test_spec.rb +++ b/spec/jasmine_self_test_spec.rb @@ -1,9 +1,16 @@ require 'spec_helper' -require 'jasmine_self_test_config' -jasmine_runner_config = Jasmine::RunnerConfig.new(JasmineSelfTestConfig.new) -server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config)) -client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url) +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(config.port, Jasmine::Application.app(config)) +driver = Jasmine::SeleniumDriver.new(config.browser, "#{config.host}:#{config.port}/") t = Thread.new do begin @@ -13,10 +20,10 @@ # # ignore bad exits end t.abort_on_exception = true -Jasmine::wait_for_listener(jasmine_runner_config.port, "jasmine server") +Jasmine::wait_for_listener(config.port, "jasmine server") puts "jasmine server started." -results_processor = Jasmine::ResultsProcessor.new(jasmine_runner_config) -results = Jasmine::Runners::HTTP.new(client, results_processor, jasmine_runner_config.result_batch_size).run +results_processor = Jasmine::ResultsProcessor.new(config) +results = Jasmine::Runners::HTTP.new(driver, results_processor, config.result_batch_size).run formatter = Jasmine::RspecFormatter.new formatter.format_results(results) diff --git a/spec/page_spec.rb b/spec/page_spec.rb index b2db7df2..448a8703 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -6,15 +6,13 @@ describe "#render" do subject { Nokogiri::HTML(page.render) } let(:fake_config) do - OpenStruct.new(:js_files => ["file1.js", "file2.js"], - :css_files => ["file1.css", "file2.css"], - :jasmine_files => ["jasmine_file1.js", "jasmine_file2.js"]) + OpenStruct.new(:js_files => ["file1.js", "file2.js"], :css_files => ["file1.css", "file2.css"]) end let(:context) { fake_config } let(:page) { Jasmine::Page.new(context) } it "should render javascript files in the correct order" do js_files = subject.css("script") - js_files.map { |file| file["src"] }.compact.should == ["jasmine_file1.js", "jasmine_file2.js", "file1.js", "file2.js"] + js_files.map { |file| file["src"] }.compact.should == ["file1.js", "file2.js"] end it "should render css files in the correct order" do diff --git a/spec/path_expander_spec.rb b/spec/path_expander_spec.rb new file mode 100644 index 00000000..1eea3b3c --- /dev/null +++ b/spec/path_expander_spec.rb @@ -0,0 +1,96 @@ +require 'spec_helper' + +describe Jasmine::PathExpander do + it "returns absolute paths" do + dir_glob = lambda do |pattern| + case pattern + when 'some_base/src1*' + ['some_base/src1.js', 'some_base/src15.js'] + when 'some_base/src2*' + ['some_base/src2.js'] + else + raise "Unexpected pattern received: #{pattern}" + end + end + + expanded_files = Jasmine::PathExpander.expand( + 'some_base', + ['src1*', 'src2*'], + dir_glob + ) + + expanded_files.should == [ + File.join('some_base', 'src1.js'), + File.join('some_base', 'src15.js'), + File.join('some_base', 'src2.js') + ] + end + + it "uniqs files" do + dir_glob = lambda do |pattern| + case pattern + when 'some_base/src1*' + ['some_base/src1.js', 'some_base/src15.js', 'some_base/src1.js'] + when 'some_base/src2*' + ['some_base/src2.js'] + else + raise "Unexpected pattern received: #{pattern}" + end + end + + expanded_files = Jasmine::PathExpander.expand( + 'some_base', + ['src1*', 'src2*'], + dir_glob + ) + + expanded_files.should == [ + File.join('some_base', 'src1.js'), + File.join('some_base', 'src15.js'), + File.join('some_base', 'src2.js') + ] + end + + it "supports negation of passed patterns" do + dir_glob = lambda do |pattern| + case pattern + when 'some_base/src1*' + ['some_base/src1.js', 'some_base/src15.js'] + when 'some_base/src1.js' + ['some_base/src1.js'] + when 'some_base/src2*' + ['some_base/src2.js'] + else + raise "Unexpected pattern received: #{pattern}" + end + end + + expanded_files = Jasmine::PathExpander.expand( + 'some_base', + ['src1*', '!src1.js', 'src2*'], + dir_glob + ) + + expanded_files.should == [ + File.join('some_base', 'src15.js'), + File.join('some_base', 'src2.js') + ] + end + + it "passes through files that are not found by the globber and are not negations and not globs" do + #this is designed to support asset pipeline files that aren't found. + dir_glob = lambda do |pattern| + [] + end + + expanded_files = Jasmine::PathExpander.expand( + 'some_base', + ['src1*', '!src1.js', 'src2.js'], + dir_glob + ) + + expanded_files.should == [ + File.join('some_base', 'src2.js') + ] + end +end diff --git a/spec/path_mapper_spec.rb b/spec/path_mapper_spec.rb new file mode 100644 index 00000000..55f7d55e --- /dev/null +++ b/spec/path_mapper_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Jasmine::PathMapper do + it "correctly remaps src files" do + config = double(:config, :src_dir => '/src_dir', :src_path => '/__src__') + mapper = Jasmine::PathMapper.new(config) + mapper.map_src_paths(['/src_dir/foo']).should == ['/__src__/foo'] + mapper.map_src_paths(['foo/bar']).should == ['/__src__/foo/bar'] + end + it "correctly remaps spec files" do + config = double(:config, :spec_dir => '/spec_dir', :spec_path => '/__spec__') + mapper = Jasmine::PathMapper.new(config) + mapper.map_spec_paths(['/spec_dir/foo']).should == ['/__spec__/foo'] + mapper.map_spec_paths(['foo/bar']).should == ['/__spec__/foo/bar'] + end + it "correctly remaps jasmine files" do + config = double(:config, :jasmine_dir => '/jasmine_dir', :jasmine_path => '/__jasmine__') + mapper = Jasmine::PathMapper.new(config) + mapper.map_jasmine_paths(['/jasmine_dir/foo']).should == ['/__jasmine__/foo'] + mapper.map_jasmine_paths(['foo/bar']).should == ['/__jasmine__/foo/bar'] + end + it "correctly remaps boot files" do + config = double(:config, :boot_dir => '/boot_dir', :boot_path => '/__boot__') + mapper = Jasmine::PathMapper.new(config) + mapper.map_boot_paths(['/boot_dir/foo']).should == ['/__boot__/foo'] + mapper.map_boot_paths(['foo/bar']).should == ['/__boot__/foo/bar'] + end + it "handles edge case where dir == path" do + config = double(:config, :src_dir => '/src_dir', :src_path => '/src_dir') + mapper = Jasmine::PathMapper.new(config) + mapper.map_src_paths(['/src_dir/foo']).should == ['/src_dir/foo'] + end +end diff --git a/spec/runner_config_spec.rb b/spec/runner_config_spec.rb deleted file mode 100644 index c5d1d757..00000000 --- a/spec/runner_config_spec.rb +++ /dev/null @@ -1,136 +0,0 @@ -require 'spec_helper' -require 'selenium-webdriver' - -describe Jasmine::RunnerConfig do - describe "css_files" do - it "should return the jasmine stylesheets and any user defined stylesheets" do - jasmine_stylesheets = ['some/css/file'] - user_stylesheets = ['some/user/file'] - user_config = double("config", :jasmine_stylesheets => jasmine_stylesheets, :user_stylesheets => user_stylesheets) - Jasmine::RunnerConfig.new(user_config).css_files.should == jasmine_stylesheets + user_stylesheets - end - end - - describe "jasmine_files" do - it "should return the jasmine files from the config" do - jasmine_files = ['some/file'] - user_config = double('config', :jasmine_javascripts => jasmine_files) - Jasmine::RunnerConfig.new(user_config).jasmine_files.should == jasmine_files - end - end - - describe "js_files" do - it "should return the user js files from the config" do - js_files = ['some/file'] - user_config = double('config', :js_files => js_files) - Jasmine::RunnerConfig.new(user_config).js_files.should == js_files - end - end - - describe "spec_files" do - it "should return the user spec_files from the config" do - spec_files = ['some/file'] - user_config = double('config', :spec_files => spec_files) - Jasmine::RunnerConfig.new(user_config).spec_files.should == spec_files - end - end - - describe "spec_files_full_paths" do - it "should return the user spec_files_full_paths from the config" do - spec_files_full_paths = ['some/file_path'] - user_config = double('config', :spec_files_full_paths => spec_files_full_paths) - Jasmine::RunnerConfig.new(user_config).spec_files_full_paths.should == spec_files_full_paths - end - end - - describe "spec_path" do - it "should return the user spec_path from the config" do - spec_path = ['some/path'] - user_config = double('config', :spec_path => spec_path) - Jasmine::RunnerConfig.new(user_config).spec_path.should == spec_path - end - end - - describe "spec_dir" do - it "should return the user spec_dir from the config" do - spec_dir = ['some/dir'] - user_config = double('config', :spec_dir => spec_dir) - Jasmine::RunnerConfig.new(user_config).spec_dir.should == spec_dir - end - end - - describe "src_dir" do - it "should return the user src_dir from the config" do - src_dir = ['some/dir'] - user_config = double('config', :src_dir => src_dir) - Jasmine::RunnerConfig.new(user_config).src_dir.should == src_dir - end - end - - describe "project_root" do - it "should return the user project_root from the config" do - project_root = ['some/dir'] - user_config = double('config', :project_root => project_root) - Jasmine::RunnerConfig.new(user_config).project_root.should == project_root - end - end - - describe "root_path" do - it "should return the user root_path from the config" do - root_path = ['some/path'] - user_config = double('config', :root_path => root_path) - Jasmine::RunnerConfig.new(user_config).root_path.should == root_path - end - end - - describe "browser" do - it "should default to firefox" do - Jasmine::RunnerConfig.new.browser.should == 'firefox' - end - - it "should use ENV['JASMINE_BROWSER'] if it exists" do - ENV.stub(:[], "JASMINE_BROWSER").and_return("foo") - Jasmine::RunnerConfig.new.browser.should == 'foo' - end - end - - - describe "src_mapper" do - it "should update the src_mapper in the user_config" do - config = Jasmine::RunnerConfig.new(user_config = Jasmine::Config.new) - mapper = double("mapper") - config.src_mapper = mapper - config.src_mapper.should == mapper - user_config.src_mapper.should == mapper - end - end - - describe "jasmine_server_url" do - it "should return the correct server url" do - host = "the host" - port = "484" - user_config = double('config', :jasmine_host => host, :port => port) - Jasmine::RunnerConfig.new(user_config).jasmine_server_url.should == "#{host}:#{port}/" - end - end - - describe "port" do - it "should return the port from the config" do - user_config = double('config', :port => 80) - Jasmine::RunnerConfig.new(user_config).port.should == 80 - end - end - describe "result batch size" do - subject { Jasmine::RunnerConfig.new.result_batch_size } - - context "when not specified" do - it("should use default") { should == 50 } - end - - context "when overridden" do - before { ENV.stub(:[], "JASMINE_RESULT_BATCH_SIZE").and_return("500") } - it { should be(500) } - end - end -end - diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 4275b4f7..f2333b71 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -27,14 +27,14 @@ it "should create a Rack::Server with the correct port when passed" do port = 1234 Rack::Server.should_receive(:new).with(hash_including(:Port => port)).and_return(double(:server).as_null_object) - Jasmine::Server.new(port).start + Jasmine::Server.new(port, double(:app)).start end it "should start the server" do server = double(:server) Rack::Server.should_receive(:new) { server.as_null_object } server.should_receive(:start) - Jasmine::Server.new.start + Jasmine::Server.new('8888', double(:app)).start end it "should set the app as the instance variable on the rack server" do diff --git a/spec/yaml_config_parser_spec.rb b/spec/yaml_config_parser_spec.rb new file mode 100644 index 00000000..67c0da99 --- /dev/null +++ b/spec/yaml_config_parser_spec.rb @@ -0,0 +1,156 @@ +require 'spec_helper' + +describe Jasmine::YamlConfigParser do + # before :each do + # Jasmine::Dependencies.stub(:rails_3_asset_pipeline?) { false } + + # temp_dir_before + + # Dir::chdir @tmp + # dir_name = "test_js_project" + # `mkdir -p #{dir_name}` + # Dir::chdir dir_name + # `#{@root}/bin/jasmine init .` + + # @project_dir = Dir.pwd + + # @template_dir = File.expand_path(File.join(@root, "generators/jasmine/templates")) + # @config = Jasmine::Config.new + # end + + # after(:each) do + # temp_dir_after + # end + + it "src_dir uses current working directory when src dir is blank" do + yaml_loader = lambda do |path| + if path == "some_path" + {"src_dir" => nil} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.src_dir.should == 'some_project_root' + end + + it "src_dir returns src_dir if set" do + yaml_loader = lambda do |path| + if path == "some_path" + {"src_dir" => 'some_src_dir'} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.src_dir.should == File.join('some_project_root', 'some_src_dir') + end + + it "spec_dir uses default path when spec dir is blank" do + yaml_loader = lambda do |path| + if path == "some_path" + {"spec_dir" => nil} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.spec_dir.should == File.join('some_project_root', 'spec', 'javascripts') + end + + it "spec_dir returns spec_dir if set" do + yaml_loader = lambda do |path| + if path == "some_path" + {"spec_dir" => "some_spec_dir"} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.spec_dir.should == File.join('some_project_root', 'some_spec_dir') + end + + it "expands src_file paths" do + expander = lambda do |dir, patterns| + if (dir == File.join('some_project_root', 'some_src') && patterns == ['some_patterns']) + ['expected_results'] + end + end + yaml_loader = lambda do |path| + if path == "some_path" + { 'src_dir' => 'some_src', 'src_files' => ['some_patterns'] } + end + end + + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', expander, yaml_loader) + + parser.src_files.should == ['expected_results'] + end + + it "expands stylesheets paths" do + expander = lambda do |dir, patterns| + if (dir == File.join('some_project_root', 'some_src') && patterns == ['some_patterns']) + ['expected_results'] + end + end + yaml_loader = lambda do |path| + if path == "some_path" + { 'src_dir' => 'some_src', 'stylesheets' => ['some_patterns'] } + end + end + + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', expander, yaml_loader) + + parser.css_files.should == ['expected_results'] + end + + it "expands spec_file paths" do + expander = lambda do |dir, patterns| + if (dir == File.join('some_project_root', 'some_spec') && patterns == ['some_patterns']) + ['expected_results'] + end + end + yaml_loader = lambda do |path| + if path == "some_path" + { 'spec_dir' => 'some_spec', 'spec_files' => ['some_patterns'] } + end + end + + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', expander, yaml_loader) + + parser.spec_files.should == ['expected_results'] + end + + it "expands helper paths" do + expander = lambda do |dir, patterns| + if (dir == File.join('some_project_root', 'some_spec') && patterns == ['some_patterns']) + ['expected_results'] + end + end + yaml_loader = lambda do |path| + if path == "some_path" + { 'spec_dir' => 'some_spec', 'helpers' => ['some_patterns'] } + end + end + + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', expander, yaml_loader) + + parser.helpers.should == ['expected_results'] + end + + it "doesn't blow up when blank values are passed" do + expander = lambda do |dir, patterns| + raise 'bad arguments' unless patterns.is_a?(Array) + [] + end + yaml_loader = lambda do |path| + {} + end + + parser = Jasmine::YamlConfigParser.new({}, 'some_project_root', expander, yaml_loader) + parser.src_files.should == [] + parser.spec_files.should == [] + parser.css_files.should == [] + parser.helpers.should == [] + end + + + # it "should parse ERB" do + # @config.stub!(:simple_config_file).and_return(File.expand_path(File.join(@root, 'spec', 'fixture','jasmine.erb.yml'))) + # Dir.stub!(:glob).and_return { |glob_string| [glob_string] } + # @config.src_files.should == ['file0.js', 'file1.js', 'file2.js',] + # end + +end From e69648a9a070b12f11c951cca65a88879d52fb1c Mon Sep 17 00:00:00 2001 From: "Davis W. Frank & Rajan Agaskar" Date: Tue, 27 Nov 2012 11:56:57 -0800 Subject: [PATCH 40/53] Re-add support for asset pipeline --- lib/jasmine.rb | 3 +- lib/jasmine/asset_expander.rb | 19 ++++++++++++ lib/jasmine/asset_pipeline_mapper.rb | 25 +++++++--------- lib/jasmine/asset_pipeline_utility.rb | 19 ++++++++++++ lib/jasmine/config.rb | 24 ++++++++++++++- lib/jasmine/configuration.rb | 2 +- lib/jasmine/sprockets_mapper.rb | 13 --------- spec/asset_expander_spec.rb | 42 +++++++++++++++++++++++++++ spec/asset_pipeline_mapper_spec.rb | 23 ++++++++------- spec/configuration_spec.rb | 12 ++++---- spec/sprockets_mapper_spec.rb | 17 ----------- 11 files changed, 135 insertions(+), 64 deletions(-) create mode 100644 lib/jasmine/asset_expander.rb create mode 100644 lib/jasmine/asset_pipeline_utility.rb delete mode 100644 lib/jasmine/sprockets_mapper.rb create mode 100644 spec/asset_expander_spec.rb delete mode 100644 spec/sprockets_mapper_spec.rb diff --git a/lib/jasmine.rb b/lib/jasmine.rb index 6e7d3016..f35d2353 100644 --- a/lib/jasmine.rb +++ b/lib/jasmine.rb @@ -10,8 +10,9 @@ 'command_line_tool', 'page', 'path_mapper', + 'asset_pipeline_utility', 'asset_pipeline_mapper', - 'sprockets_mapper', + 'asset_expander', 'results_processor', 'results', 'path_expander', diff --git a/lib/jasmine/asset_expander.rb b/lib/jasmine/asset_expander.rb new file mode 100644 index 00000000..484ea30d --- /dev/null +++ b/lib/jasmine/asset_expander.rb @@ -0,0 +1,19 @@ +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 + + base_asset = "#{bundled_asset.pathname.to_s.gsub(/#{src_dir}/, '')}?body=true" + bundled_asset.to_a.inject([base_asset]) do |assets, asset| + assets << "/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true" + end.flatten + end + end +end diff --git a/lib/jasmine/asset_pipeline_mapper.rb b/lib/jasmine/asset_pipeline_mapper.rb index d6e1b57c..3afaf739 100644 --- a/lib/jasmine/asset_pipeline_mapper.rb +++ b/lib/jasmine/asset_pipeline_mapper.rb @@ -1,19 +1,16 @@ -class Jasmine::AssetPipelineMapper +module Jasmine + class AssetPipelineMapper - def self.context - context = ::Rails.application.assets.context_class - context.extend(::Sprockets::Helpers::IsolatedHelper) - context.extend(::Sprockets::Helpers::RailsHelper) - end + def initialize(config, asset_expander) + @config = config + @asset_expander = asset_expander + end - def initialize(context = Jasmine::AssetPipelineMapper.context) - @context = context - 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 - def files(src_files) - src_files.map do |src_file| - filename = src_file.gsub(/^assets\//, '').gsub(/\.js$/, '') - @context.asset_paths.asset_for(filename, 'js').to_a.map { |p| @context.asset_path(p).gsub(/^\//, '') + "?body=true" } - end.flatten.uniq end end diff --git a/lib/jasmine/asset_pipeline_utility.rb b/lib/jasmine/asset_pipeline_utility.rb new file mode 100644 index 00000000..1b8efb31 --- /dev/null +++ b/lib/jasmine/asset_pipeline_utility.rb @@ -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 diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index 36307f92..5a920ad1 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -8,7 +8,8 @@ def self.initialize_config @config = Jasmine::Configuration.new core_config = Jasmine::CoreConfiguration.new - @config.add_path_mapper(Jasmine::PathMapper) + @config.add_path_mapper(Jasmine::PathMapper.method(:new)) + @config.jasmine_path = jasmine_path = "/__jasmine__" @config.src_path = src_path = "/" @config.spec_path = spec_path = "/__spec__" @@ -32,6 +33,27 @@ def self.initialize_config @config.add_rack_app(Rack::Head) @config.add_rack_app(Rack::Jasmine::CacheControl) + + if Jasmine::Dependencies.rails_3_asset_pipeline? + @config.add_path_mapper(lambda { |config| + asset_expander = Jasmine::AssetExpander.new( + Jasmine::AssetPipelineUtility.method(:bundled_asset_factory), + Jasmine::AssetPipelineUtility.method(:asset_path_for) + ) + Jasmine::AssetPipelineMapper.new(config, asset_expander.method(:expand)) + }) + @config.add_rack_path('/assets', lambda { + # In order to have asset helpers like asset_path and image_path, we need to require 'action_view/base'. This + # triggers run_load_hooks on action_view which, in turn, causes sprockets/railtie to load the Sprockets asset + # helpers. Alternatively, you can include the helpers yourself without loading action_view/base: + Rails.application.assets.context_class.instance_eval do + include ::Sprockets::Helpers::IsolatedHelper + include ::Sprockets::Helpers::RailsHelper + end + Rails.application.assets + }) + end + end def self.config diff --git a/lib/jasmine/configuration.rb b/lib/jasmine/configuration.rb index 5014be87..92c4e5bd 100644 --- a/lib/jasmine/configuration.rb +++ b/lib/jasmine/configuration.rb @@ -48,7 +48,7 @@ def add_rack_app(app, &block) end def add_path_mapper(mapper) - @path_mappers << mapper.new(self) + @path_mappers << mapper.call(self) end def port diff --git a/lib/jasmine/sprockets_mapper.rb b/lib/jasmine/sprockets_mapper.rb deleted file mode 100644 index 6af625a1..00000000 --- a/lib/jasmine/sprockets_mapper.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Jasmine::SprocketsMapper - def initialize(context, mount_point = 'assets') - @context = context - @mount_point = mount_point - end - - def files(src_files) - src_files.map do |src_file| - filename = src_file.gsub(/^assets\//, '').gsub(/\.js$/, '') - @context.find_asset(filename).to_a.map(&:logical_path).map(&:to_s) - end.flatten.uniq.map{|path| File.join(@mount_point, path).to_s + "?body=true"} - end -end diff --git a/spec/asset_expander_spec.rb b/spec/asset_expander_spec.rb new file mode 100644 index 00000000..d47d9eec --- /dev/null +++ b/spec/asset_expander_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe Jasmine::AssetExpander do + it "expands asset files" do + bundled_asset = double(:bundled_asset, + :to_a => ['asset1', 'asset2'], + :pathname => double(:pathname, :to_s => '/some_src_dir/asset_file')) + + bundled_asset_getter = lambda do |filepath, ext| + if filepath == 'asset_file' && ext == 'js' + bundled_asset + end + end + + asset_path_getter = lambda do |asset| + if asset == 'asset1' + 'asset1_path' + elsif asset == 'asset2' + 'asset2_path' + end + end + + expander = Jasmine::AssetExpander.new(bundled_asset_getter, asset_path_getter) + expanded_assets = expander.expand('/some_src_dir', 'asset_file') + expanded_assets.should == ['/asset_file?body=true', + '/asset1_path?body=true', + '/asset2_path?body=true'] + end + + it "return nil if no bundled asset is found" do + bundled_asset = nil + bundled_asset_getter = lambda do |filepath, ext| + if filepath == 'asset_file' && ext == 'js' + bundled_asset + end + end + + expander = Jasmine::AssetExpander.new(bundled_asset_getter, lambda {}) + expanded_assets = expander.expand('/some_src_dir', 'asset_file') + expanded_assets.should be_nil + end +end diff --git a/spec/asset_pipeline_mapper_spec.rb b/spec/asset_pipeline_mapper_spec.rb index 1f9e6ae4..15ac7772 100644 --- a/spec/asset_pipeline_mapper_spec.rb +++ b/spec/asset_pipeline_mapper_spec.rb @@ -1,18 +1,19 @@ require 'spec_helper' describe Jasmine::AssetPipelineMapper do - describe "mapping files" do - it "should retrieve asset paths from the asset pipeline for passed files" do - #TODO: this expects all src files to be asset pipeline files - src_files = ["assets/application.js", "assets/other_manifest.js"] - asset_context = double("asset context") - asset_context.stub_chain(:asset_paths, :asset_for).with("application", "js").and_return(['asset1.js', 'asset2.js']) - asset_context.stub_chain(:asset_paths, :asset_for).with("other_manifest", "js").and_return(['asset1.js', 'asset3.js']) - asset_context.stub(:asset_path) do |asset| - "/some_location/#{asset}" + it "expands asset paths if available" do + expander = lambda do |dir, path| + if dir == "/some_location/" && path == 'asset1' + ['asset1', 'asset2'] + elsif dir == "/some_location/" && path == 'asset2' + ['asset1', 'asset3'] end - mapper = Jasmine::AssetPipelineMapper.new(asset_context) - mapper.files(src_files).should == ['some_location/asset1.js?body=true', 'some_location/asset2.js?body=true', 'some_location/asset3.js?body=true'] + end + config = double(:config, :src_dir => "/some_location/") + + mapper = Jasmine::AssetPipelineMapper.new(config, expander) + + mapper.map_src_paths(['asset1', 'asset2', 'asset4']).should == ['asset1', 'asset2', 'asset3', 'asset4'] end end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index 3380130b..9eda6a75 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -50,9 +50,9 @@ def initialize(config) describe "returning css files" do it "returns mapped jasmine_css_files + css_files" do config = Jasmine::Configuration.new() - config.add_path_mapper(test_mapper1) - config.add_path_mapper(test_mapper2) - config.add_path_mapper(test_mapper3) + config.add_path_mapper(lambda { |c| test_mapper1.new(c) }) + config.add_path_mapper(lambda { |c| test_mapper2.new(c) }) + config.add_path_mapper(lambda { |c| test_mapper3.new(c) }) config.css_files.should == [] config.jasmine_css_files = lambda { ["jasmine_css"] } config.css_files = lambda { ["css"] } @@ -63,9 +63,9 @@ def initialize(config) describe "returning javascript files" do it "returns the jasmine core files, then srcs, then specs, then boot" do config = Jasmine::Configuration.new() - config.add_path_mapper(test_mapper1) - config.add_path_mapper(test_mapper2) - config.add_path_mapper(test_mapper3) + config.add_path_mapper(lambda { |c| test_mapper1.new(c) }) + config.add_path_mapper(lambda { |c| test_mapper2.new(c) }) + config.add_path_mapper(lambda { |c| test_mapper3.new(c) }) config.js_files.should == [] config.jasmine_files = lambda { ['jasmine'] } config.src_files = lambda { ['src'] } diff --git a/spec/sprockets_mapper_spec.rb b/spec/sprockets_mapper_spec.rb deleted file mode 100644 index bc5acfa5..00000000 --- a/spec/sprockets_mapper_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe Jasmine::SprocketsMapper do - describe "mapping files" do - it "should retrieve asset paths from the the sprockets environment for passed files" do - src_files = ["assets/application.js", "assets/other_manifest.js"] - asset1 = double("asset1", :logical_path => "asset1.js") - asset2 = double("asset2", :logical_path => "asset2.js") - asset3 = double("asset3", :logical_path => "asset3.js") - asset_context = double("Sprockets::Environment") - asset_context.stub_chain(:find_asset).with("application").and_return([asset1, asset2]) - asset_context.stub_chain(:find_asset).with("other_manifest").and_return([asset1, asset3]) - mapper = Jasmine::SprocketsMapper.new(asset_context, 'some_location') - mapper.files(src_files).should == ['some_location/asset1.js?body=true', 'some_location/asset2.js?body=true', 'some_location/asset3.js?body=true'] - end - end -end From 5c64c2645110c0357b23a6b5cacf65fa2f615544 Mon Sep 17 00:00:00 2001 From: "Davis W. Frank & Rajan Agaskar" Date: Wed, 28 Nov 2012 11:10:56 -0800 Subject: [PATCH 41/53] jasmine.yml support for jasmine_files, css, dir - Only used if non-empty --- lib/jasmine/config.rb | 3 ++ lib/jasmine/yaml_config_parser.rb | 13 ++++++ spec/yaml_config_parser_spec.rb | 75 ++++++++++++++++++++++--------- 3 files changed, 70 insertions(+), 21 deletions(-) diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index 5a920ad1..d85abeaa 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -66,6 +66,9 @@ def self.load_configuration_from_yaml(path = nil) if File.exist?(path) yaml_config = Jasmine::YamlConfigParser.new(path, Dir.pwd, Jasmine::PathExpander.method(:expand), YAML.method(:load_file)) Jasmine.configure do |config| + config.jasmine_dir = yaml_config.jasmine_dir if yaml_config.jasmine_dir + config.jasmine_files = lambda { yaml_config.jasmine_files } if yaml_config.jasmine_files.any? + config.jasmine_css_files = lambda { yaml_config.jasmine_css_files } if yaml_config.jasmine_css_files.any? config.src_files = lambda { yaml_config.src_files } config.spec_files = lambda { yaml_config.helpers + yaml_config.spec_files } config.css_files = lambda { yaml_config.css_files } diff --git a/lib/jasmine/yaml_config_parser.rb b/lib/jasmine/yaml_config_parser.rb index 017b2faf..a7d3cd83 100644 --- a/lib/jasmine/yaml_config_parser.rb +++ b/lib/jasmine/yaml_config_parser.rb @@ -17,10 +17,23 @@ def spec_dir File.join(@pwd, loaded_yaml['spec_dir']) end + def jasmine_dir + return nil unless loaded_yaml['jasmine_dir'] + File.join(@pwd, loaded_yaml['jasmine_dir']) + end + def src_files @path_expander.call(src_dir, loaded_yaml['src_files'] || []) end + def jasmine_files + @path_expander.call(jasmine_dir, loaded_yaml['jasmine_files'] || []) + end + + def jasmine_css_files + @path_expander.call(jasmine_dir, loaded_yaml['jasmine_css_files'] || []) + end + def spec_files @path_expander.call(spec_dir, loaded_yaml['spec_files'] || []) end diff --git a/spec/yaml_config_parser_spec.rb b/spec/yaml_config_parser_spec.rb index 67c0da99..0aca54a8 100644 --- a/spec/yaml_config_parser_spec.rb +++ b/spec/yaml_config_parser_spec.rb @@ -1,27 +1,6 @@ require 'spec_helper' describe Jasmine::YamlConfigParser do - # before :each do - # Jasmine::Dependencies.stub(:rails_3_asset_pipeline?) { false } - - # temp_dir_before - - # Dir::chdir @tmp - # dir_name = "test_js_project" - # `mkdir -p #{dir_name}` - # Dir::chdir dir_name - # `#{@root}/bin/jasmine init .` - - # @project_dir = Dir.pwd - - # @template_dir = File.expand_path(File.join(@root, "generators/jasmine/templates")) - # @config = Jasmine::Config.new - # end - - # after(:each) do - # temp_dir_after - # end - it "src_dir uses current working directory when src dir is blank" do yaml_loader = lambda do |path| if path == "some_path" @@ -42,6 +21,26 @@ parser.src_dir.should == File.join('some_project_root', 'some_src_dir') end + it "jasmine_dir returns nil when jasmine dir is blank" do + yaml_loader = lambda do |path| + if path == "some_path" + {"jasmine_dir" => nil} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.jasmine_dir.should be_nil + end + + it "jasmine_dir returns jasmine_dir if set" do + yaml_loader = lambda do |path| + if path == "some_path" + {"jasmine_dir" => 'some_jasmine_dir'} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.jasmine_dir.should == File.join('some_project_root', 'some_jasmine_dir') + end + it "spec_dir uses default path when spec dir is blank" do yaml_loader = lambda do |path| if path == "some_path" @@ -113,6 +112,40 @@ parser.spec_files.should == ['expected_results'] end + it "expands jasmine_file paths" do + expander = lambda do |dir, patterns| + if (dir == File.join('some_project_root', 'some_jasmine') && patterns == ['some_patterns']) + ['expected_results'] + end + end + yaml_loader = lambda do |path| + if path == "some_path" + { 'jasmine_dir' => 'some_jasmine', 'jasmine_files' => ['some_patterns'] } + end + end + + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', expander, yaml_loader) + + parser.jasmine_files.should == ['expected_results'] + end + + it "expands jasmine css file paths" do + expander = lambda do |dir, patterns| + if (dir == File.join('some_project_root', 'some_jasmine') && patterns == ['some_patterns']) + ['expected_results'] + end + end + yaml_loader = lambda do |path| + if path == "some_path" + { 'jasmine_dir' => 'some_jasmine', 'jasmine_css_files' => ['some_patterns'] } + end + end + + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', expander, yaml_loader) + + parser.jasmine_css_files.should == ['expected_results'] + end + it "expands helper paths" do expander = lambda do |dir, patterns| if (dir == File.join('some_project_root', 'some_spec') && patterns == ['some_patterns']) From c9daa599b09ac4c4cc9b566b2797a212d5ac26db Mon Sep 17 00:00:00 2001 From: "Davis W. Frank & Rajan Agaskar" Date: Wed, 28 Nov 2012 11:24:08 -0800 Subject: [PATCH 42/53] Jasmine.yml should permit ERB blocks --- lib/jasmine/config.rb | 6 +++++- spec/yaml_config_parser_spec.rb | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index d85abeaa..d3fe6540 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -1,4 +1,5 @@ module Jasmine + require 'erb' def self.configure(&block) block.call(self.config) end @@ -64,7 +65,10 @@ def self.config def self.load_configuration_from_yaml(path = nil) path ||= File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine.yml') if File.exist?(path) - yaml_config = Jasmine::YamlConfigParser.new(path, Dir.pwd, Jasmine::PathExpander.method(:expand), YAML.method(:load_file)) + yaml_loader = lambda do |filepath| + YAML::load(ERB.new(File.read(filepath)).result(binding)) if File.exist?(filepath) + end + yaml_config = Jasmine::YamlConfigParser.new(path, Dir.pwd, Jasmine::PathExpander.method(:expand), yaml_loader) Jasmine.configure do |config| config.jasmine_dir = yaml_config.jasmine_dir if yaml_config.jasmine_dir config.jasmine_files = lambda { yaml_config.jasmine_files } if yaml_config.jasmine_files.any? diff --git a/spec/yaml_config_parser_spec.rb b/spec/yaml_config_parser_spec.rb index 0aca54a8..bd74229c 100644 --- a/spec/yaml_config_parser_spec.rb +++ b/spec/yaml_config_parser_spec.rb @@ -179,11 +179,4 @@ parser.helpers.should == [] end - - # it "should parse ERB" do - # @config.stub!(:simple_config_file).and_return(File.expand_path(File.join(@root, 'spec', 'fixture','jasmine.erb.yml'))) - # Dir.stub!(:glob).and_return { |glob_string| [glob_string] } - # @config.src_files.should == ['file0.js', 'file1.js', 'file2.js',] - # end - end From 2afdf2b690d79d4e4582900becab15ff9d36c395 Mon Sep 17 00:00:00 2001 From: "Davis W. Frank & Rajan Agaskar" Date: Mon, 3 Dec 2012 09:53:09 -0800 Subject: [PATCH 43/53] Version 1.3.1 - Version lock to jasmine-core 1.3.1 --- jasmine.gemspec | 2 +- lib/jasmine/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jasmine.gemspec b/jasmine.gemspec index 3ffd3aeb..5fa3f050 100644 --- a/jasmine.gemspec +++ b/jasmine.gemspec @@ -67,7 +67,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'json_pure' s.add_development_dependency 'nokogiri' - s.add_dependency 'jasmine-core', ">= 1.3.0" + 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' diff --git a/lib/jasmine/version.rb b/lib/jasmine/version.rb index 1cc58d7a..9a854860 100644 --- a/lib/jasmine/version.rb +++ b/lib/jasmine/version.rb @@ -1,3 +1,3 @@ module Jasmine - VERSION = "1.3.0" + VERSION = "1.3.1" end From c5b2c9d428c2078fb5ca21797458c74bb06edbc4 Mon Sep 17 00:00:00 2001 From: Koji NAKAMURA Date: Tue, 4 Dec 2012 18:26:10 +0900 Subject: [PATCH 44/53] fix reference error of YAML and JSON config.rb needs `require 'yaml'` and selenium_driver.rb needs `require 'json'` in case of `rake jasmine:ci` --- lib/jasmine/config.rb | 1 + lib/jasmine/selenium_driver.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index d3fe6540..631ae06c 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -1,4 +1,5 @@ module Jasmine + require 'yaml' require 'erb' def self.configure(&block) block.call(self.config) diff --git a/lib/jasmine/selenium_driver.rb b/lib/jasmine/selenium_driver.rb index 134b3997..85f03ad3 100644 --- a/lib/jasmine/selenium_driver.rb +++ b/lib/jasmine/selenium_driver.rb @@ -1,4 +1,5 @@ module Jasmine + require 'json' class SeleniumDriver def initialize(browser, http_address) require 'selenium-webdriver' From 5d1d500fdc2462951de901513f2aacc5286f20c1 Mon Sep 17 00:00:00 2001 From: Rajan Agaskar Date: Fri, 7 Dec 2012 09:11:42 -0800 Subject: [PATCH 45/53] Remove obsolete Rails-guesswork from jasmine init - Rails generators should be used for Rails installs. --- lib/jasmine/command_line_tool.rb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/jasmine/command_line_tool.rb b/lib/jasmine/command_line_tool.rb index 7bb7ac1b..bdbe1bfc 100644 --- a/lib/jasmine/command_line_tool.rb +++ b/lib/jasmine/command_line_tool.rb @@ -36,23 +36,17 @@ 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') + 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| From 478c6027a19f391c4fc3ca0faef001915ee7906f Mon Sep 17 00:00:00 2001 From: "Davis W. Frank & Rajan Agaskar" Date: Fri, 7 Dec 2012 09:13:14 -0800 Subject: [PATCH 46/53] Version bump to 1.3.2 - Bugfixes --- lib/jasmine/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jasmine/version.rb b/lib/jasmine/version.rb index 9a854860..c0547fae 100644 --- a/lib/jasmine/version.rb +++ b/lib/jasmine/version.rb @@ -1,3 +1,3 @@ module Jasmine - VERSION = "1.3.1" + VERSION = "1.3.2" end From 63e8d46556a421cbb3b511b52cd8c2188d72b9db Mon Sep 17 00:00:00 2001 From: ragaskar Date: Fri, 11 Jan 2013 07:46:29 -0800 Subject: [PATCH 47/53] Load jasmine_helper after configuring from yaml - Allows users opportunity to add a Jasmine.configure block that overrides/augments jasmine.yml settings - File defaults to specs/javascript/support/jasmine_helper.rb but is configurable from jasmine.yml - *Only* processed if using jasmine.yml (which default rake tasks will do if jasmine.yml exists). --- generators/jasmine/jasmine_generator.rb | 1 + .../spec/javascripts/support/jasmine.yml | 14 +++++++++++++ .../javascripts/support/jasmine_helper.rb | 11 ++++++++++ .../javascripts/support/jasmine_helper.rb | 11 ++++++++++ lib/jasmine/command_line_tool.rb | 1 + lib/jasmine/config.rb | 2 +- lib/jasmine/yaml_config_parser.rb | 4 ++++ spec/yaml_config_parser_spec.rb | 20 +++++++++++++++++++ 8 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb create mode 100644 lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb diff --git a/generators/jasmine/jasmine_generator.rb b/generators/jasmine/jasmine_generator.rb index 157f0282..e79de77a 100644 --- a/generators/jasmine/jasmine_generator.rb +++ b/generators/jasmine/jasmine_generator.rb @@ -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" diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine.yml b/generators/jasmine/templates/spec/javascripts/support/jasmine.yml index dc3d7e53..1e773424 100644 --- a/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +++ b/generators/jasmine/templates/spec/javascripts/support/jasmine.yml @@ -72,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 + + diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb b/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb new file mode 100644 index 00000000..986a4c16 --- /dev/null +++ b/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb @@ -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 +# + diff --git a/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb b/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb new file mode 100644 index 00000000..986a4c16 --- /dev/null +++ b/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb @@ -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 +# + diff --git a/lib/jasmine/command_line_tool.rb b/lib/jasmine/command_line_tool.rb index bdbe1bfc..447d8a00 100644 --- a/lib/jasmine/command_line_tool.rb +++ b/lib/jasmine/command_line_tool.rb @@ -37,6 +37,7 @@ def process(argv) copy_unless_exists('jasmine-example/spec/SpecHelper.js', 'spec/javascripts/helpers/SpecHelper.js') 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')) diff --git a/lib/jasmine/config.rb b/lib/jasmine/config.rb index 631ae06c..6098b253 100644 --- a/lib/jasmine/config.rb +++ b/lib/jasmine/config.rb @@ -22,7 +22,6 @@ def self.initialize_config @config.boot_files = lambda { core_config.boot_files } @config.jasmine_files = lambda { core_config.js_files } @config.jasmine_css_files = lambda { core_config.css_files } - @config.add_rack_path(jasmine_path, lambda { Rack::File.new(config.jasmine_dir) }) @config.add_rack_path(boot_path, lambda { Rack::File.new(config.boot_dir) }) @config.add_rack_path(spec_path, lambda { Rack::File.new(config.spec_dir) }) @@ -80,6 +79,7 @@ def self.load_configuration_from_yaml(path = nil) config.src_dir = yaml_config.src_dir config.spec_dir = yaml_config.spec_dir end + require yaml_config.spec_helper if File.exist?(yaml_config.spec_helper) end end diff --git a/lib/jasmine/yaml_config_parser.rb b/lib/jasmine/yaml_config_parser.rb index a7d3cd83..e6cc3054 100644 --- a/lib/jasmine/yaml_config_parser.rb +++ b/lib/jasmine/yaml_config_parser.rb @@ -46,6 +46,10 @@ def css_files @path_expander.call(src_dir, loaded_yaml['stylesheets'] || []) end + def spec_helper + File.join(@pwd, loaded_yaml['spec_helper'] || File.join('spec', 'javascripts', 'support', 'jasmine_helper.rb')) + end + private def loaded_yaml @yaml_loader.call(@path) diff --git a/spec/yaml_config_parser_spec.rb b/spec/yaml_config_parser_spec.rb index bd74229c..2fbafba5 100644 --- a/spec/yaml_config_parser_spec.rb +++ b/spec/yaml_config_parser_spec.rb @@ -41,6 +41,26 @@ parser.jasmine_dir.should == File.join('some_project_root', 'some_jasmine_dir') end + it "spec_helper returns default helper path when spec_helper is blank" do + yaml_loader = lambda do |path| + if path == "some_path" + {"spec_helper" => nil} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.spec_helper.should == 'some_project_root/spec/javascripts/support/jasmine_helper.rb' + end + + it "spec_helper returns spec_helper if set" do + yaml_loader = lambda do |path| + if path == "some_path" + {"spec_helper" => 'some_spec_helper.rb'} + end + end + parser = Jasmine::YamlConfigParser.new('some_path', 'some_project_root', nil, yaml_loader) + parser.spec_helper.should == 'some_project_root/some_spec_helper.rb' + end + it "spec_dir uses default path when spec dir is blank" do yaml_loader = lambda do |path| if path == "some_path" From be9851192e78ffe635087e5583b15ebe683dc0d9 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Sat, 19 Jan 2013 15:33:32 -0800 Subject: [PATCH 48/53] Remove incorrect asset_path mapping - Including 'asset_file' (the manifest) fails if asset file is itself templated (erb, coffee), or if asset file uses require_self. - Use require_self if it is necessary to include javascript inside of a sprockets manifest file (like application.js) --- lib/jasmine/asset_expander.rb | 5 ++--- spec/asset_expander_spec.rb | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/jasmine/asset_expander.rb b/lib/jasmine/asset_expander.rb index 484ea30d..7f0f287b 100644 --- a/lib/jasmine/asset_expander.rb +++ b/lib/jasmine/asset_expander.rb @@ -10,9 +10,8 @@ def expand(src_dir, src_path) bundled_asset = @bundled_asset_factory.call(pathname, 'js') return nil unless bundled_asset - base_asset = "#{bundled_asset.pathname.to_s.gsub(/#{src_dir}/, '')}?body=true" - bundled_asset.to_a.inject([base_asset]) do |assets, asset| - assets << "/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true" + bundled_asset.to_a.map do |asset| + "/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true" end.flatten end end diff --git a/spec/asset_expander_spec.rb b/spec/asset_expander_spec.rb index d47d9eec..b14fc027 100644 --- a/spec/asset_expander_spec.rb +++ b/spec/asset_expander_spec.rb @@ -22,8 +22,7 @@ expander = Jasmine::AssetExpander.new(bundled_asset_getter, asset_path_getter) expanded_assets = expander.expand('/some_src_dir', 'asset_file') - expanded_assets.should == ['/asset_file?body=true', - '/asset1_path?body=true', + expanded_assets.should == ['/asset1_path?body=true', '/asset2_path?body=true'] end From b952a71d8c0321dd6c913a0f0ec76ebd7b801946 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 22 Jan 2013 10:50:49 -0800 Subject: [PATCH 49/53] Fix jasmine_helper.rb generator example Remove the instance variable notation. --- .../templates/spec/javascripts/support/jasmine_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb b/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb index 986a4c16..b4919802 100644 --- a/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +++ b/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb @@ -4,8 +4,8 @@ # #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'] } +# config.boot_dir = '/absolute/path/to/boot_dir' +# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } #end # From aca2ee622992c9c6e469b88c74143995125f63fa Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 22 Jan 2013 10:39:35 -0800 Subject: [PATCH 50/53] Remove reference to jasmine_config.rb in README --- README.markdown | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.markdown b/README.markdown index f1171d3a..0ea49a50 100644 --- a/README.markdown +++ b/README.markdown @@ -53,8 +53,6 @@ This uses Selenium to launch a browser and run the Jasmine suite. Then it uses R 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. From b087b38d7429da4c61aedb8042a001274a123dc0 Mon Sep 17 00:00:00 2001 From: Levent Ali Date: Wed, 30 Jan 2013 14:29:23 +0000 Subject: [PATCH 51/53] Remove references to jasmine_config.rb and jasmine_runner.rb in USAGE --- lib/generators/jasmine/install/USAGE | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/generators/jasmine/install/USAGE b/lib/generators/jasmine/install/USAGE index 03147927..b0c9fe16 100644 --- a/lib/generators/jasmine/install/USAGE +++ b/lib/generators/jasmine/install/USAGE @@ -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 From e3e124dcde15d9fc6995390bcee7c2c536ab4bdd Mon Sep 17 00:00:00 2001 From: "Davis W. Frank" Date: Mon, 11 Mar 2013 14:02:48 -0700 Subject: [PATCH 52/53] Added release notes for v1.3.2 --- jasmine.gemspec | 2 ++ .../v1.2.1.md | 2 +- release_notes/v1.3.2.md | 32 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) rename RELEASE_NOTES.markdown => release_notes/v1.2.1.md (91%) create mode 100644 release_notes/v1.3.2.md diff --git a/jasmine.gemspec b/jasmine.gemspec index 5fa3f050..3a0c2560 100644 --- a/jasmine.gemspec +++ b/jasmine.gemspec @@ -67,6 +67,8 @@ Gem::Specification.new do |s| s.add_development_dependency 'json_pure' s.add_development_dependency 'nokogiri' + 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' diff --git a/RELEASE_NOTES.markdown b/release_notes/v1.2.1.md similarity index 91% rename from RELEASE_NOTES.markdown rename to release_notes/v1.2.1.md index 9de3bf5a..acc9d7b5 100644 --- a/RELEASE_NOTES.markdown +++ b/release_notes/v1.2.1.md @@ -1,4 +1,4 @@ -#1.2.1 +# Jasmine Gem v1.2.1 * asset manifests following the Rails defaults are included as individual src files * Fix regression that required Jasmine restart to find new src/spec files diff --git a/release_notes/v1.3.2.md b/release_notes/v1.3.2.md new file mode 100644 index 00000000..438b58ab --- /dev/null +++ b/release_notes/v1.3.2.md @@ -0,0 +1,32 @@ +# Jasmine Gem v1.3.2 + +## Summary + +This release removes some pre-1.3 cruft in documentation regarding the old configuration files. Also fixes the JSON/YAML require bug. + +Best approach is to delete your Jasmine support files and clean out jasmine from your Rakefile and call `jasmine init` again. + +## Changes + +* Removed incorrect asset_path mapping + * Including `asset_file` (the manifest) fails if asset file is itself templated (erb, coffee), or if asset file uses `require_self`. + * Use `require_self` if it is necessary to include javascript inside of a Sprockets manifest file (like `application.js`) + * SHA: [be9851192e78ffe635087e5583b15ebe683dc0d9](http://github.com/pivotal/jasmine-gem/commit/be9851192e78ffe635087e5583b15ebe683dc0d9) +* Load `jasmine_helper` after configuring from yaml + * Allows users opportunity to add a `Jasmine.configure` block that overrides/augments `jasmine.yml` settings + * File defaults to `specs/javascript/support/jasmine_helper.rb` but is configurable from `jasmine.yml` + * *Only* processed if using `jasmine.yml` (which default rake tasks will do if `jasmine.yml` exists). + * SHA: [63e8d46556a421cbb3b511b52cd8c2188d72b9db](http://github.com/pivotal/jasmine-gem/commit/63e8d46556a421cbb3b511b52cd8c2188d72b9db) +* Rails generators should be used for Rails installs + * SHA: [5d1d500fdc2462951de901513f2aacc5286f20c1](http://github.com/pivotal/jasmine-gem/commit/5d1d500fdc2462951de901513f2aacc5286f20c1) +* Fix reference error of YAML and JSON + * Merge pull request #119 from kozy4324 + * SHA: [442135f648970fcaf5e4163a672a78fbea65e118](http://github.com/pivotal/jasmine-gem/commit/442135f648970fcaf5e4163a672a78fbea65e118) +* Removed references in docs to pre-1.3 files that are no longer used + * Merged pull request #132 from levent + * Merged pull request #129 from mcolyer + * Merged pull request #130 from mcolyer + +------ + +_Release Notes generated with [Anchorman](http://github.com/infews/anchorman)_ \ No newline at end of file From 5c76ab960e48701e66ca63c46990575d29b8210f Mon Sep 17 00:00:00 2001 From: zephyr-dev Date: Fri, 15 Mar 2013 11:41:37 -0300 Subject: [PATCH 53/53] Demonstrate Gemfile definition. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some members of our team tried to only put the gem into the :test group.  We thought we'd make the installation clearer on the Readme. -- Adam and Steve --- README.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.markdown b/README.markdown index 0ea49a50..8b8e17b8 100644 --- a/README.markdown +++ b/README.markdown @@ -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