bobtest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +1 -0
  2. data/lib/Bt.rb +15 -0
  3. data/lib/bob_test.rb +76 -0
  4. metadata +57 -0
data/README ADDED
@@ -0,0 +1 @@
1
+ HIYO!
data/lib/Bt.rb ADDED
@@ -0,0 +1,15 @@
1
+ class Bt
2
+
3
+ def run_tests
4
+ self.class.send(:methods_to_test).all?{|meth| self.send meth.intern}
5
+ end
6
+
7
+ def sassy
8
+ puts "FUCK OFF"
9
+ end
10
+
11
+ def self.methods_to_test
12
+ self.new.methods - self.methods - ['run_tests']
13
+ end
14
+
15
+ end
data/lib/bob_test.rb ADDED
@@ -0,0 +1,76 @@
1
+ # get_line and get_lines unabashedly stolen from the command_history.rb file in the Utility Belt gem.
2
+ module BobTest
3
+ def self.included(base)
4
+ base.send :extend, ClassMethods
5
+ end
6
+ module ClassMethods
7
+ require 'ftools'
8
+ class << self; attr_accessor :test; end
9
+
10
+ def start_test(name = Time.now.to_s)
11
+ @test = BobTest.new
12
+ @test.name = name
13
+ @test.start_line = Readline::HISTORY.size - 1
14
+ end
15
+
16
+ # todo figure out why there's an off by 1 error. Would expect size - 1 to be the last command.
17
+ def end_test
18
+ @test.end_line = Readline::HISTORY.size - 3
19
+ @test.get_lines(@test.start_line..@test.end_line)
20
+ path_to_file = File.expand_path(File.dirname(__FILE__)) + "/../bob/test/unit/"
21
+ File.makedirs(path_to_file)
22
+ filename ="#{self.class_name.underscore}_bob_test.rb"
23
+ filename_with_path = path_to_file + filename
24
+ File.open(filename_with_path, 'w+') do |f|
25
+ f.write("class #{self.class_name}BobTest < Bt\nend\n")
26
+ end unless File.exists?(filename_with_path)
27
+ @test.write_to_file(filename_with_path)
28
+ end
29
+ end
30
+
31
+
32
+ # need to figure out what File.open('/path/to/file', 'wb' ) does # the wb part. (w means write, b means binary)
33
+ # commands.rb in rails source
34
+
35
+ class BobTest
36
+
37
+ attr_accessor :name, :start_line, :end_line, :contents, :indentable_words
38
+
39
+ @indentable_words = %w{begin break case def do else elsif end ensure if in next redo rescue retry return
40
+ super then unless until when while yield}
41
+
42
+ def get_lines(lines = [])
43
+ out = []
44
+ lines = lines.to_a if lines.is_a? Range
45
+ lines.each do |l|
46
+ out << Readline::HISTORY[l]
47
+ end
48
+ @contents = out
49
+ end
50
+
51
+ def write_to_file(file)
52
+ File.open(file, 'r+') do |f|
53
+ lines = f.readlines
54
+ e = lines.pop
55
+ until e.eql?("end\n")
56
+ e = lines.pop
57
+ break if lines.empty?
58
+ end
59
+ f.pos = 0
60
+ f.write lines
61
+ f.write " def #{name.gsub(/\W/,'_')}\n"
62
+ @contents.each do |line|
63
+ f.write " #{line}\n"
64
+ end
65
+ f.write " end\n"
66
+ f.write e
67
+ f.truncate f.pos
68
+ end
69
+ # gonna have to run a file indenter !
70
+ # gotta figure out how to load the files this produces
71
+ # pluginify this
72
+ end
73
+
74
+ end
75
+
76
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bobtest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - deathbob
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-07 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: bobtest is dangerous.
17
+ email: larrick@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - lib/Bt.rb
27
+ - lib/bob_test.rb
28
+ has_rdoc: true
29
+ homepage: http://github.com/deathbob/bob_test
30
+ licenses: []
31
+
32
+ post_install_message:
33
+ rdoc_options: []
34
+
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project:
52
+ rubygems_version: 1.3.5
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: bobtest is a testing strategy for people named bob.
56
+ test_files: []
57
+