Permalink
Browse files

make sure src_files can also be loaded from other asset paths, should…

… fix problem found by @christiannelson
  • Loading branch information...
1 parent 0d45505 commit 142a0c974b77d19d9645b78401126349eed1f324 @johnbintz committed Jan 24, 2012
View
11 features/bin/two_files_from_src_files.feature
@@ -0,0 +1,11 @@
+Feature: Two files from source files
+ Scenario: Files are ordered directly
+ Given I have a test suite
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/two_files_from_src_files/jasmine.yml -l`
+ Then the exit status should be 0
+ And the following files should be loaded in order:
+ | vendor/vendor-file.js |
+ | vendor/vendor.js |
+ | app/app-file.js |
+ | app/app.js |
+
View
10 features/steps/then/bin/following_files_loaded_in_order.rb
@@ -0,0 +1,10 @@
+Then /^the following files should be loaded in order:$/ do |table|
+ files = table.raw.flatten
+
+ @output.lines.collect(&:strip).each do |line|
+ files.shift if line[files.first]
+ end
+
+ files.should be_empty
+end
+
View
26 lib/jasmine/headless/files_list.rb
@@ -227,13 +227,13 @@ def use_config
end
def add_files(patterns, type, dirs)
- dirs.product(patterns).each do |search|
- files = expanded_dir(File.join(*search))
+ patterns.each do |pattern|
+ dirs.collect { |dir| expanded_dir(File.join(dir, pattern)) }.each do |files|
+ files.sort! { |a, b| Kernel.rand(3) - 1 } if type == 'spec_files'
- files.sort! { |a, b| Kernel.rand(3) - 1 } if type == 'spec_files'
-
- files.each do |path|
- add_path(path, type)
+ files.each do |path|
+ add_path(path, type)
+ end
end
end
@@ -271,25 +271,31 @@ def add_path(path, type = nil)
end
def src_dir
- @src_dir ||= config_dir_or_pwd('src_dir')
+ @src_dir ||= config_dir_or_pwd('src_dir') + asset_paths
end
def spec_dir
@spec_dir ||= config_dir_or_pwd('spec_dir')
end
def asset_paths
- @asset_paths ||= config_dir_or_pwd('asset_paths')
+ @asset_paths ||= config_dir('asset_paths')
end
def spec_file_searches
@searches['spec_files']
end
def config_dir_or_pwd(dir)
- found_dir = (@options[:config] && @options[:config][dir]) || Dir.pwd
+ if (found = config_dir(dir)).empty?
+ found = [ Dir.pwd ]
+ end
+
+ found
+ end
- [ found_dir ].flatten.collect { |dir| File.expand_path(dir) }
+ def config_dir(dir)
+ [ @options[:config] && @options[:config][dir] ].flatten.compact.collect { |dir| File.expand_path(dir) }
end
def filter_for_requested_specs(files)
View
0 spec/jasmine/two_files_from_src_files/app/app-file.js
No changes.
View
2 spec/jasmine/two_files_from_src_files/app/app.js
@@ -0,0 +1,2 @@
+//= require app-file
+//
View
7 spec/jasmine/two_files_from_src_files/jasmine.yml
@@ -0,0 +1,7 @@
+src_dir: spec/jasmine/two_files_from_src_files/app
+
+asset_paths:
+- "spec/jasmine/two_files_from_src_files/vendor"
+
+src_files: [ 'vendor.js', 'app.js' ]
+
View
0 spec/jasmine/two_files_from_src_files/vendor/vendor-file.js
No changes.
View
2 spec/jasmine/two_files_from_src_files/vendor/vendor.js
@@ -0,0 +1,2 @@
+//= require vendor-file
+//

1 comment on commit 142a0c9

@christiannelson

@johnbintz I tried this out and it's working well. We'll give it a spin for the next couple of days and let you know how it goes. Thanks!

Please sign in to comment.