Permalink
Browse files

Made it so the rake task doesn't explode if you're too cool to use Rails

  • Loading branch information...
1 parent c67f8db commit ccaab1c8f3891d04e1e68479e4d3f273ce2525d3 @zspencer zspencer committed Jun 28, 2011
Showing with 31 additions and 8 deletions.
  1. +11 −8 lib/jasmine/headless/task.rb
  2. +20 −0 spec/lib/jasmine/headless/task_spec.rb
@@ -42,15 +42,18 @@ def initialize(name = 'jasmine:headless')
:jasmine_config => @jasmine_config
)
end
-
- if Rails.version >= "3.1.0"
- desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
- task 'assets:precompile:for_testing' => :environment do
- Rails.application.assets.digest_class = Digest::JasmineTest
-
- Rake::Task['assets:precompile'].invoke
+ create_rails_compliant_task if defined?(Rails)
+ end
+ private
+ def create_rails_compliant_task
+ if Rails.version >= "3.1.0"
+ desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
+ task 'assets:precompile:for_testing' => :environment do
+ Rails.application.assets.digest_class = Digest::JasmineTest
+
+ Rake::Task['assets:precompile'].invoke
+ end
end
- end
end
end
end
@@ -0,0 +1,20 @@
+require 'spec_helper'
+require 'fakefs/spec_helpers'
+require 'jasmine/headless/task'
+
+module Jasmine
+ module Headless
+ class Task
+ def desc(block)
+ end
+ def task(block)
+ end
+ end
+ end
+end
+describe Jasmine::Headless::Task do
+ it 'should not explode when Rails is undefined' do
+ Jasmine::Headless::Task.new('jasmine:headless') do |t|
+ end
+ end
+end

0 comments on commit ccaab1c

Please sign in to comment.