vendored helpers support, take a look at jasmine-spec-extras
This commit is contained in:
parent
8503d86aba
commit
2aabba2cd7
@ -115,8 +115,17 @@ module Jasmine
|
||||
@filtered_files = @files.dup
|
||||
|
||||
data = @options[:config].dup
|
||||
[ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].each do |searches, root|
|
||||
[ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'vendored_helpers' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].each do |searches, root|
|
||||
if data[searches]
|
||||
case searches
|
||||
when 'vendored_helpers'
|
||||
data[searches].each do |name, version|
|
||||
found_files = self.class.find_vendored_asset_path(name, version)
|
||||
|
||||
@files += found_files
|
||||
@filtered_files += found_files
|
||||
end
|
||||
else
|
||||
data[searches].flatten.collect do |search|
|
||||
path = search
|
||||
path = File.join(data[root], path) if data[root]
|
||||
@ -140,6 +149,7 @@ module Jasmine
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def config?
|
||||
@options[:config]
|
||||
@ -148,6 +158,16 @@ module Jasmine
|
||||
def expanded_dir(path)
|
||||
Dir[path].collect { |file| File.expand_path(file) }
|
||||
end
|
||||
|
||||
def self.find_vendored_asset_path(name, version)
|
||||
require 'rubygems'
|
||||
|
||||
Gem::Specification.map { |spec|
|
||||
spec.files.find_all { |file|
|
||||
file["vendor/assets/#{name}/#{version}"]
|
||||
}.collect { |file| File.join(spec.gem_dir, file) }
|
||||
}.flatten.compact
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ require 'fakefs/spec_helpers'
|
||||
require 'coffee-script'
|
||||
|
||||
describe Jasmine::FilesList do
|
||||
let(:files_list) { Jasmine::FilesList.new }
|
||||
let(:files_list) { described_class.new }
|
||||
|
||||
describe '#initialize' do
|
||||
it "should have default files" do
|
||||
@ -22,7 +22,7 @@ describe Jasmine::FilesList do
|
||||
end
|
||||
|
||||
describe '#use_config' do
|
||||
let(:files_list) { Jasmine::FilesList.new(:config => config) }
|
||||
let(:files_list) { described_class.new(:config => config) }
|
||||
|
||||
include FakeFS::SpecHelpers
|
||||
|
||||
@ -81,6 +81,28 @@ describe Jasmine::FilesList do
|
||||
|
||||
it_should_behave_like :reading_data
|
||||
end
|
||||
|
||||
context 'with vendored helpers' do
|
||||
let(:config) { {
|
||||
'src_dir' => src_dir,
|
||||
'spec_dir' => spec_dir,
|
||||
'src_files' => [ 'js/first_file.js', 'js/*.js' ],
|
||||
'spec_files' => [ '*_spec.js' ],
|
||||
'helpers' => [],
|
||||
'stylesheets' => [ 'stylesheet/*.css' ],
|
||||
'vendored_helpers' => { 'one' => 'version' }
|
||||
} }
|
||||
|
||||
let(:helper_file) { "path/one/version.js" }
|
||||
|
||||
before do
|
||||
described_class.expects(:find_vendored_asset_path).with('one', 'version').returns([ helper_file ])
|
||||
end
|
||||
|
||||
it 'should find the vendored file' do
|
||||
files_list.files.should include(helper_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with filtered specs' do
|
||||
|
Loading…
Reference in New Issue
Block a user