Permalink
Browse files

use mocha mocking instead of punching ducks

  • Loading branch information...
1 parent 343fd6f commit 7316f77367b83f45fd01ccf34e27469a0516a227 @johnbintz johnbintz committed Jun 28, 2011
Showing with 31 additions and 31 deletions.
  1. +11 −10 lib/jasmine/headless/task.rb
  2. +20 −21 spec/lib/jasmine/headless/task_spec.rb
View
21 lib/jasmine/headless/task.rb
@@ -9,7 +9,7 @@ def self.file(file)
def file(file)
self
end
-
+
def hexdigest
'test'
end
@@ -37,23 +37,24 @@ def initialize(name = 'jasmine:headless')
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
41 spec/lib/jasmine/headless/task_spec.rb
@@ -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')
+ describe 'define task' do
+ before do
+ Jasmine::Headless::Task.any_instance.stubs(:desc)
+ Jasmine::Headless::Task.any_instance.stubs(:task)
end
- end
- context 'with Rails' do
- before do
- module Rails
- def self.version
- return "0"
- 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

0 comments on commit 7316f77

Please sign in to comment.