-
-
Save joselo/2378795 to your computer and use it in GitHub Desktop.
Revisions
-
baphled revised this gist
Sep 11, 2011 . 2 changed files with 25 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ # Needed if you are not requiring rails/all require 'sprockets/railtie' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,13 +8,24 @@ module Jasmine class Config include Rake::DSL def js_files(spec_filter = nil) # remove all generated files generated_files_directory = File.expand_path("../generated", __FILE__) # @TODO actually remove generated specs # # Think we need to include the rake DSL to make use of rm_rf now # rm_rf generated_files_directory, :secure => true precompile_app_assets compile_jasmine_javascripts # this is code from the original jasmine config js_files method - you could also just alias_method_chain it spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter]) src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) } end private @@ -27,13 +38,21 @@ def precompile_app_assets ::Rake.application['environment'].invoke # temporarily set the static assets location from public/assets to our spec directory # # This line is now redundant as sprockets does not use static_root to store assets any more # #::Rails.application.config.assets.static_root = Rails.root.join("spec/javascripts/generated/assets") # Sprockets seems to think that assets always belong in the public directory # Though it's a bit hackish we remove the assets from the public directory after we're done # # Would be nicer if sprockets allowed for a way for us to precompile our assets in the generated directory # Thats something to look into for later. # ::Rake.application['assets:clean'].reenable ::Rake.application['assets:clean'].invoke # rake won't let you run the same task twice in the same process without re-enabling it # once the assets have been cleared, recompile them into the spec directory ::Rake.application['assets:precompile'].reenable ::Rake.application['assets:precompile'].invoke @@ -49,7 +68,7 @@ def compile_jasmine_javascripts Dir.glob(glob).each do |srcfile| srcfile = Pathname.new(srcfile) destfile = srcfile.sub(root, destination_dir).sub(".coffee", "") FileUtils.mkdir_p(destfile.dirname) File.open(destfile, "w") {|f| f.write(CoffeeScript.compile(File.new(srcfile)))} end -
baphled revised this gist
Sep 1, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def precompile_app_assets ::Rake.application['environment'].invoke # temporarily set the static assets location from public/assets to our spec directory ::Rails.application.config.assets.static_root = Rails.root.join("spec/javascripts/generated/assets") # rake won't let you run the same task twice in the same process without re-enabling it # so reenable the "clean" task and run it -
baphled revised this gist
Jul 24, 2011 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # # Would be nice to have this set within jasmine.yml. # config.assets.precompile += %w( application.js form.js frontend.js *.css ) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,7 @@ def precompile_app_assets # this method compiles all of the spec files into js files that jasmine can run def compile_jasmine_javascripts puts "Compiling jasmine coffee scripts into javascript..." root = File.expand_path("../../../../spec/javascripts", __FILE__) destination_dir = File.expand_path("../../generated/specs", __FILE__) glob = File.expand_path("**/*.coffee", root) -
baphled created this gist
Jul 23, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ # spec/javascripts/support/jasmine_config.rb # when jasmine starts the server out-of-process, it needs this in order to be able to invoke the asset tasks unless Object.const_defined?(:Rake) require 'rake' load File.expand_path('../../../../Rakefile', __FILE__) end module Jasmine class Config def js_files(spec_filter = nil) precompile_app_assets compile_jasmine_javascripts # this is code from the original jasmine config js_files method - you could also just alias_method_chain it spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter]) src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) } end private # this method compiles all the same javascript files your app will def precompile_app_assets puts "Precompiling assets..." # make sure the Rails environment is loaded ::Rake.application['environment'].invoke # temporarily set the static assets location from public/assets to our spec directory ::Rails.application.assets.static_root = Rails.root.join("spec/javascripts/generated/assets") # rake won't let you run the same task twice in the same process without re-enabling it # so reenable the "clean" task and run it ::Rake.application['assets:clean'].reenable ::Rake.application['assets:clean'].invoke # once the assets have been cleared, recompile them into the spec directory ::Rake.application['assets:precompile'].reenable ::Rake.application['assets:precompile'].invoke end # this method compiles all of the spec files into js files that jasmine can run def compile_jasmine_javascripts puts "Compiling jasmine coffee scripts into javascript..." root = File.expand_path("../../../../spec/javascripts/coffee", __FILE__) destination_dir = File.expand_path("../../generated/specs", __FILE__) glob = File.expand_path("**/*.coffee", root) Dir.glob(glob).each do |srcfile| srcfile = Pathname.new(srcfile) destfile = srcfile.sub(root, destination_dir).sub(".coffee", ".js") FileUtils.mkdir_p(destfile.dirname) File.open(destfile, "w") {|f| f.write(CoffeeScript.compile(File.new(srcfile)))} end end end end # Note - this is necessary for rspec2, which has removed the backtrace module Jasmine class SpecBuilder def declare_spec(parent, spec) me = self example_name = spec["name"] @spec_ids << spec["id"] backtrace = @example_locations[parent.description + " " + example_name] parent.it example_name, {} do me.report_spec(spec["id"]) end end end end