Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SpecReader
- module Test
- module Unit
- class TestCase
- end
- end
- end
- def initialize
- mock
- yield self
- unmock
- end
- def require(*args)
- # don't do anything
- end
- def context(name)
- puts name
- yield
- end
- def specify(name)
- puts "- #{name}"
- end
- def mock
- Object.class_eval do
- def method_missing_with_spec_reader_mock(*args)
- # don't do anything
- end
- alias_method :method_missing_without_spec_reader_mock, :method_missing
- alias_method :method_missing, :method_missing_with_spec_reader_mock
- end
- Module.class_eval do
- def const_missing_with_spec_reader_mock(*args)
- Object
- end
- alias_method :const_missing_without_spec_reader_mock, :const_missing
- alias_method :const_missing, :const_missing_with_spec_reader_mock
- def include_with_spec_reader_mock(*args)
- # don't do anything
- end
- alias_method :include_without_spec_reader_mock, :include
- alias_method :include, :include_with_spec_reader_mock
- end
- end
- def unmock
- Object.send(:alias_method, :method_missing, :method_missing_without_spec_reader_mock)
- Module.send(:alias_method, :const_missing, :const_missing_without_spec_reader_mock)
- Module.send(:alias_method, :include, :include_without_spec_reader_mock)
- end
- end
- namespace :spec do
- desc "Prints out the specs without running the associated tests"
- task :describe do
- SpecReader.new do |reader|
- Dir[File.dirname(__FILE__) + '/../../../../test/**/*_test.rb'].each do |path|
- reader.instance_eval(File.read(path), path, 1)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment