-
Notifications
You must be signed in to change notification settings - Fork 27
/
Rakefile
48 lines (41 loc) · 1.21 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'memfs'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
desc 'Compares a MemFs class to the original Ruby one ' \
'(set CLASS to the compared class)'
task :compare do
class_name = ENV['CLASS'] || 'File'
klass = Object.const_get(class_name)
memfs_klass = MemFs.const_get(class_name)
original_methods = (klass.methods - Object.methods).sort
original_i_methods = (klass.instance_methods - Object.methods).sort
implemented_methods = MemFs.activate { (memfs_klass.methods - Object.methods).sort }
implemented_i_methods = MemFs.activate { (memfs_klass.instance_methods - Object.methods).sort }
puts "CLASS: #{class_name}"
puts
puts 'MISSING CLASS METHODS'
puts
puts original_methods - implemented_methods
puts
puts 'MISSING INSTANCE METHODS'
puts
puts original_i_methods - implemented_i_methods
puts
puts 'ADDITIONAL METHODS'
puts
puts implemented_methods - original_methods
puts
puts 'ADDITIONAL INSTANCE METHODS'
puts
puts implemented_i_methods - original_i_methods
end
task :console do
require 'irb'
require 'irb/completion'
require 'memfs'
ARGV.clear
IRB.start
end