Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request johnbintz#28 from zspencer/master
Browse files Browse the repository at this point in the history
Fixed defect with using the Rake Task without having Rails installed
  • Loading branch information
johnbintz committed Jun 28, 2011
2 parents c67f8db + 3b214f9 commit 96e071a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/jasmine/headless/task.rb
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions spec/lib/jasmine/headless/task_spec.rb
@@ -0,0 +1,30 @@
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
Object.send(:remove_const, :Rails) if defined?(Rails)
Jasmine::Headless::Task.new('jasmine:headless') do |t|
end
end
it 'should be OK if rails is defined' do
module Rails
def self.version
return "0"
end
end
Jasmine::Headless::Task.new('jasmine:headless') do |t|
end
end
end

0 comments on commit 96e071a

Please sign in to comment.