Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jasmine.yml support for jasmine_files, css, dir

- Only used if non-empty
  • Loading branch information...
commit 5c64c2645110c0357b23a6b5cacf65fa2f615544 1 parent e69648a
Davis W. Frank & Rajan Agaskar authored
View
3  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 }
View
13 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
View
75 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'])
Please sign in to comment.
Something went wrong with that request. Please try again.