use mocha mocking instead of punching ducks
This commit is contained in:
parent
343fd6f84b
commit
7316f77367
@ -44,16 +44,17 @@ module Jasmine
|
|||||||
end
|
end
|
||||||
create_rails_compliant_task if defined?(Rails)
|
create_rails_compliant_task if defined?(Rails)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def create_rails_compliant_task
|
def create_rails_compliant_task
|
||||||
if Rails.version >= "3.1.0"
|
if Rails.version >= "3.1.0"
|
||||||
desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
|
desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
|
||||||
task 'assets:precompile:for_testing' => :environment do
|
task 'assets:precompile:for_testing' => :environment do
|
||||||
Rails.application.assets.digest_class = Digest::JasmineTest
|
Rails.application.assets.digest_class = Digest::JasmineTest
|
||||||
|
|
||||||
Rake::Task['assets:precompile'].invoke
|
Rake::Task['assets:precompile'].invoke
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,38 +1,37 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'fakefs/spec_helpers'
|
require 'fakefs/spec_helpers'
|
||||||
require 'jasmine/headless/task'
|
require 'jasmine/headless/task'
|
||||||
|
require 'mocha'
|
||||||
module Jasmine
|
|
||||||
module Headless
|
|
||||||
class Task
|
|
||||||
def desc(block); end
|
|
||||||
def task(block); end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe Jasmine::Headless::Task do
|
describe Jasmine::Headless::Task do
|
||||||
after do
|
after do
|
||||||
Object.send(:remove_const, :Rails) if defined?(Rails)
|
Object.send(:remove_const, :Rails) if defined?(Rails)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without Rails' do
|
describe 'define task' do
|
||||||
it 'should not explode when Rails is undefined' do
|
|
||||||
Jasmine::Headless::Task.new('jasmine:headless')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with Rails' do
|
|
||||||
before do
|
before do
|
||||||
module Rails
|
Jasmine::Headless::Task.any_instance.stubs(:desc)
|
||||||
def self.version
|
Jasmine::Headless::Task.any_instance.stubs(:task)
|
||||||
return "0"
|
end
|
||||||
end
|
|
||||||
|
context 'without Rails' do
|
||||||
|
it 'should not explode when Rails is undefined' do
|
||||||
|
Jasmine::Headless::Task.new('jasmine:headless')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be OK if rails is defined' do
|
context 'with Rails' do
|
||||||
Jasmine::Headless::Task.new('jasmine:headless')
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user