From 1b8a4804b7fb8335f9c14c17540f210d56b51bba Mon Sep 17 00:00:00 2001 From: ragaskar Date: Wed, 27 Jan 2010 19:50:39 -0800 Subject: [PATCH] Rename jasmine.yaml to jasmine.yml. --- bin/jasmine | 4 +- generators/jasmine/jasmine_generator.rb | 2 +- .../javascripts/support/jasmine-rails.yaml | 10 ----- .../javascripts/support/jasmine-rails.yml | 20 +++++++++ .../spec/javascripts/support/jasmine.yaml | 10 ----- .../spec/javascripts/support/jasmine.yml | 20 +++++++++ jasmine.gemspec | 6 +-- spec/config_spec.rb | 41 ++++++++++++------- 8 files changed, 72 insertions(+), 41 deletions(-) delete mode 100644 generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yaml create mode 100644 generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml delete mode 100644 generators/jasmine/templates/spec/javascripts/support/jasmine.yaml create mode 100644 generators/jasmine/templates/spec/javascripts/support/jasmine.yml diff --git a/bin/jasmine b/bin/jasmine index cc597ec..f7e688d 100755 --- a/bin/jasmine +++ b/bin/jasmine @@ -37,9 +37,9 @@ if ARGV[0] == 'init' 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.yaml', 'spec/javascripts/support/jasmine.yaml') + copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml') else - copy_unless_exists('spec/javascripts/support/jasmine.yaml') + copy_unless_exists('spec/javascripts/support/jasmine.yml') write_mode = 'w' if File.exist?(dest_path('Rakefile')) load dest_path('Rakefile') diff --git a/generators/jasmine/jasmine_generator.rb b/generators/jasmine/jasmine_generator.rb index a87decc..231b0b5 100644 --- a/generators/jasmine/jasmine_generator.rb +++ b/generators/jasmine/jasmine_generator.rb @@ -9,7 +9,7 @@ class JasmineGenerator < Rails::Generator::Base m.directory "spec/javascripts/support" m.file "spec/javascripts/support/jasmine_config.rb", "spec/javascripts/support/jasmine_config.rb" m.file "spec/javascripts/support/jasmine_spec.rb", "spec/javascripts/support/jasmine_spec.rb" - m.file "spec/javascripts/support/jasmine-rails.yaml", "spec/javascripts/support/jasmine.yaml" + m.file "spec/javascripts/support/jasmine-rails.yml", "spec/javascripts/support/jasmine.yml" m.directory "lib/tasks" m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake" diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yaml b/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yaml deleted file mode 100644 index 8dacb55..0000000 --- a/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yaml +++ /dev/null @@ -1,10 +0,0 @@ -src_files: - - javascripts/prototype.js - - javascripts/effects.js - - javascripts/controls.js - - javascripts/dragdrop.js - - javascripts/application.js -spec_files: - - **/*.js -src_dir: public -spec_dir: spec/javascripts diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml b/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml new file mode 100644 index 0000000..f9a282c --- /dev/null +++ b/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml @@ -0,0 +1,20 @@ +# Return an array of filepaths relative to src_dir to include before jasmine specs. +src_files: + - javascripts/prototype.js + - javascripts/effects.js + - javascripts/controls.js + - javascripts/dragdrop.js + - javascripts/application.js + +# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs. +stylesheets: + - stylesheets/**/*.css +# Return an array of filepaths relative to spec_dir to include before jasmine specs. +spec_files: + - **/*.js + +# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank. +src_dir: public + +# Spec directory path. Your spec_files must be returned relative to this path. +spec_dir: spec/javascripts diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine.yaml b/generators/jasmine/templates/spec/javascripts/support/jasmine.yaml deleted file mode 100644 index 09706ed..0000000 --- a/generators/jasmine/templates/spec/javascripts/support/jasmine.yaml +++ /dev/null @@ -1,10 +0,0 @@ -#src_files: -# - lib/source1.js -# - lib/source2.js -# - dist/**/*.js -#stylesheets: -# - css/style.css -#spec_files: -# - -#src_dir: -#spec_dir: spec/javascripts \ No newline at end of file diff --git a/generators/jasmine/templates/spec/javascripts/support/jasmine.yml b/generators/jasmine/templates/spec/javascripts/support/jasmine.yml new file mode 100644 index 0000000..f97fcf1 --- /dev/null +++ b/generators/jasmine/templates/spec/javascripts/support/jasmine.yml @@ -0,0 +1,20 @@ +# Return an array of filepaths relative to src_dir to include before jasmine specs. +#src_files: +# - lib/source1.js +# - lib/source2.js +# - dist/**/*.js + +# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs. +#stylesheets: +# - css/style.css +# - stylesheets/*.css + +# Return an array of filepaths relative to spec_dir to include before jasmine specs. +#spec_files: +# - **/*.js + +# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank. +#src_dir: + +# Spec directory path. Your spec_files must be returned relative to this path. +#spec_dir: spec/javascripts \ No newline at end of file diff --git a/jasmine.gemspec b/jasmine.gemspec index cd419e2..c68fe35 100644 --- a/jasmine.gemspec +++ b/jasmine.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Rajan Agaskar", "Christian Williams"] - s.date = %q{2010-01-26} + s.date = %q{2010-01-27} s.default_executable = %q{jasmine} s.description = %q{Javascript BDD test framework} s.email = %q{ragaskar@gmail.com} @@ -23,8 +23,8 @@ Gem::Specification.new do |s| "generators/jasmine/templates/lib/tasks/jasmine.rake", "generators/jasmine/templates/spec/javascripts/ExampleSpec.js", "generators/jasmine/templates/spec/javascripts/SpecHelper.js", - "generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yaml", - "generators/jasmine/templates/spec/javascripts/support/jasmine.yaml", + "generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml", + "generators/jasmine/templates/spec/javascripts/support/jasmine.yml", "generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb", "generators/jasmine/templates/spec/javascripts/support/jasmine_spec.rb", "jasmine/contrib/ruby/jasmine_runner.rb", diff --git a/spec/config_spec.rb b/spec/config_spec.rb index a35ed6d..133f050 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -4,11 +4,14 @@ describe Jasmine::Config do before(:each) do @template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../generators/jasmine/templates")) @config = Jasmine::Config.new - @config.stub!(:src_dir).and_return(File.join(@template_dir, "public")) - @config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec")) end - describe "simple_config" do + describe "configuration" do + before(:each) do + @config.stub!(:src_dir).and_return(File.join(@template_dir, "public")) + @config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec")) + end + it "if sources.yaml not found" do File.stub!(:exist?).and_return(false) @config.src_files.should == [] @@ -20,7 +23,7 @@ describe Jasmine::Config do } end - it "if sources.yaml is empty" do + it "if jasmine.yml is empty" do @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yaml')) YAML.stub!(:load).and_return(false) @config.src_files.should == [] @@ -32,8 +35,8 @@ describe Jasmine::Config do } end - it "using default jasmine.yaml" do - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yaml')) + it "using default jasmine.yml" do + @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml')) @config.src_files.should == [] @config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js'] @config.mappings.should == { @@ -43,7 +46,7 @@ describe Jasmine::Config do end it "simple_config stylesheets" do - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yaml')) + @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 do |glob_string| glob_string @@ -60,7 +63,7 @@ describe Jasmine::Config do original_glob.call(glob_string) end end - @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yaml')) + @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml')) @config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js'] @config.src_files.should == ['javascripts/prototype.js', 'javascripts/effects.js', @@ -77,6 +80,21 @@ describe Jasmine::Config do '/__spec__/javascripts/SpecHelper.js', ] end + + it "should provide a list of all spec files with full paths" do + @config.spec_files_full_paths.should == [ + File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'), + File.join(@template_dir, 'spec/javascripts/SpecHelper.js') + ] + end + + end + + 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 @@ -87,11 +105,4 @@ describe Jasmine::Config do } end - it "should provide a list of all spec files with full paths" do - @config.spec_files_full_paths.should == [ - File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'), - File.join(@template_dir, 'spec/javascripts/SpecHelper.js') - ] - end - end \ No newline at end of file