use mocha mocking instead of punching ducks

This commit is contained in:
John Bintz 2011-06-28 11:06:36 -04:00
parent 343fd6f84b
commit 7316f77367
2 changed files with 32 additions and 32 deletions

View File

@ -9,7 +9,7 @@ module Digest
def file(file)
self
end
def hexdigest
'test'
end
@ -37,23 +37,24 @@ module Jasmine
desc 'Run Jasmine specs headlessly'
task name do
Jasmine::Headless::Runner.run(
:colors => colors,
:remove_html_file => !@keep_on_error,
:colors => colors,
:remove_html_file => !@keep_on_error,
:jasmine_config => @jasmine_config
)
end
create_rails_compliant_task if defined?(Rails)
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
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
Rake::Task['assets:precompile'].invoke
end
end
end
end
end

View File

@ -1,38 +1,37 @@
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
require 'mocha'
describe Jasmine::Headless::Task do
after do
Object.send(:remove_const, :Rails) if defined?(Rails)
end
context 'without Rails' do
it 'should not explode when Rails is undefined' do
Jasmine::Headless::Task.new('jasmine:headless')
end
end
context 'with Rails' do
describe 'define task' do
before do
module Rails
def self.version
return "0"
end
Jasmine::Headless::Task.any_instance.stubs(:desc)
Jasmine::Headless::Task.any_instance.stubs(:task)
end
context 'without Rails' do
it 'should not explode when Rails is undefined' do
Jasmine::Headless::Task.new('jasmine:headless')
end
end
it 'should be OK if rails is defined' do
Jasmine::Headless::Task.new('jasmine:headless')
context 'with Rails' do
before do
module Rails
def self.version
return "0"
end
end
end
it 'should be OK if rails is defined' do
Jasmine::Headless::Task.new('jasmine:headless')
end
end
end
end