From dc134dcf245e1638072cfb385e7e37f2fc525a66 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 9 Sep 2011 11:49:17 -0400 Subject: [PATCH] fix the determination of spec files for line number analysis --- lib/jasmine/files_list.rb | 18 ++++++++++-------- spec/lib/jasmine/files_list_spec.rb | 10 +++++++++- .../jasmine/headless/cacheable_action_spec.rb | 1 + spec/lib/jasmine/headless/options_spec.rb | 3 +++ spec/lib/jasmine/headless/runner_spec.rb | 6 +++++- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/jasmine/files_list.rb b/lib/jasmine/files_list.rb index 14dfbf6..37beebe 100644 --- a/lib/jasmine/files_list.rb +++ b/lib/jasmine/files_list.rb @@ -4,7 +4,7 @@ require 'time' module Jasmine class FilesList - attr_reader :files, :filtered_files, :spec_outside_scope + attr_reader :files, :spec_files, :filtered_files, :spec_outside_scope DEFAULT_FILES = [ File.join(Jasmine::Core.path, "jasmine.js"), @@ -100,15 +100,17 @@ module Jasmine @files += found_files if searches == 'spec_files' - @spec_files += spec_filter + @spec_files += spec_filter.empty? ? found_files : (found_files & spec_filter) end - @filtered_files += (if searches == 'spec_files' - @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort) - spec_filter.empty? ? found_files : (spec_filter || found_files) - else - found_files - end) + @filtered_files += begin + if searches == 'spec_files' + @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort) + spec_filter.empty? ? found_files : (spec_filter || found_files) + else + found_files + end + end end end end diff --git a/spec/lib/jasmine/files_list_spec.rb b/spec/lib/jasmine/files_list_spec.rb index e6ece59..1fe9f37 100644 --- a/spec/lib/jasmine/files_list_spec.rb +++ b/spec/lib/jasmine/files_list_spec.rb @@ -36,6 +36,7 @@ describe Jasmine::FilesList do before do [ first_file, src_file, spec_file, helper_file, stylesheet_file ].each do |file| + FileUtils.mkdir_p File.split(file).first File.open(file, 'w') end end @@ -49,6 +50,8 @@ describe Jasmine::FilesList do File.expand_path(helper_file), File.expand_path(spec_file) ] + + files_list.spec_files.should == [ File.expand_path(spec_file) ] end end @@ -90,8 +93,11 @@ describe Jasmine::FilesList do 'spec_dir' => spec_dir } } + let(:spec_files) { %w{one_spec.js two_spec.js whatever.js} } + before do - %w{one_spec.js two_spec.js whatever.js}.each do |file| + spec_files.each do |file| + FileUtils.mkdir_p spec_dir File.open(File.join(spec_dir, file), 'w') end end @@ -103,6 +109,7 @@ describe Jasmine::FilesList do files_list.files.any? { |file| file['two_spec.js'] }.should be_true files_list.filtered?.should be_false files_list.should_not have_spec_outside_scope + files_list.spec_files.sort.should == %w{one_spec.js two_spec.js}.sort.collect { |file| File.expand_path(File.join(spec_dir, file)) } end end @@ -113,6 +120,7 @@ describe Jasmine::FilesList do files_list.files.any? { |file| file['two_spec.js'] }.should be_true files_list.filtered?.should be_true files_list.should_not have_spec_outside_scope + files_list.spec_files.should == filter end it 'should return only filtered files for filtered_files' do diff --git a/spec/lib/jasmine/headless/cacheable_action_spec.rb b/spec/lib/jasmine/headless/cacheable_action_spec.rb index 5e55a91..01b006f 100644 --- a/spec/lib/jasmine/headless/cacheable_action_spec.rb +++ b/spec/lib/jasmine/headless/cacheable_action_spec.rb @@ -59,6 +59,7 @@ describe Jasmine::Headless::CacheableAction do let(:cache_file_mtime) { 15 } before do + FileUtils.mkdir_p File.split(cache_file).first File.open(cache_file, 'wb') { |fh| fh.print compiled } end diff --git a/spec/lib/jasmine/headless/options_spec.rb b/spec/lib/jasmine/headless/options_spec.rb index e822da3..346bae3 100644 --- a/spec/lib/jasmine/headless/options_spec.rb +++ b/spec/lib/jasmine/headless/options_spec.rb @@ -52,6 +52,9 @@ describe Jasmine::Headless::Options do let(:test_data) { '-j test' } before do + FileUtils.mkdir_p File.split(Jasmine::Headless::Options::GLOBAL_DEFAULTS_FILE).first + FileUtils.mkdir_p File.split(Jasmine::Headless::Options::DEFAULTS_FILE).first + File.open(Jasmine::Headless::Options::GLOBAL_DEFAULTS_FILE, 'w') { |fh| fh.puts global_test_data } File.open(Jasmine::Headless::Options::DEFAULTS_FILE, 'w') { |fh| fh.puts test_data } end diff --git a/spec/lib/jasmine/headless/runner_spec.rb b/spec/lib/jasmine/headless/runner_spec.rb index bdbdd14..b3b77b7 100644 --- a/spec/lib/jasmine/headless/runner_spec.rb +++ b/spec/lib/jasmine/headless/runner_spec.rb @@ -18,8 +18,12 @@ describe Jasmine::Headless::Runner do describe '#load_config' do include FakeFS::SpecHelpers + let(:runner_filename) { 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner' } + before do - File.open('ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner', 'w') + FileUtils.mkdir_p File.split(runner_filename).first + + File.open(runner_filename, 'w') end let(:config_filename) { 'test.yml' }